Reinstantiating Ef Classes With One-to-many Relationship And Compound Key Of Strings
I have the following EF Code First classes, which appear to be working to a point. I also have Initialization code that seeds these tables with data from elsewhere that is lengthy
Solution 1:
Why SubCategories is null or with 0 item because you don't include this relation that it is Eager loading. if you want to use lazy loading you can use virtual keyword in your navigation property:
Lazy Loading:
publicvirtual List<SubCategory> SubCategories { get; set; }
Eager Loading:
db.Categories.Where(c => c.CategoryCode == "FUND").Include(x => x.SubCategories ).ToList();
Post a Comment for "Reinstantiating Ef Classes With One-to-many Relationship And Compound Key Of Strings"