Thoughts from Dan Miser RSS 2.0
# Wednesday, February 15, 2012
I had a class that looked like this:

public class CollectionDetail {
  public int Id { get; set; }
  ...
  public MachineField MachineField { get; set; }
}

I would then later write LINQ code that would end up retrieving these objects. The problem was MachineField was always set to null. I banged my head on this for a long time looking at everything I could think of. Finally, after looking at the CollectionDetail class one more time, I noticed that other Foreign Key objects were marked with virtual, and I remembered that I removed virtual while I was trying to test whether or not the object's lazy load behavior. All of the documentation clearly states that you need to mark this virtual. Once I added the virtual keyword back, everything worked exactly as it should have.

Wednesday, February 15, 2012 12:55:59 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.NET | EntityFramework
Navigation
Archive
<December 2014>
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910
Blogroll
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2014
Dan Miser
Sign In
Statistics
Total Posts: 388
This Year: 0
This Month: 0
This Week: 0
Comments: 630
Themes
Pick a theme:
All Content © 2014, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)