I am running this query but i am unsure of what is it fetching ?
var sm = pe.C开发者_如何学编程ategories.Include("ParentCategory").Where(c => c.ParentCategory.CategoryName == "Electronics");
What will the variable sm have ??
Edit - You need to remove the Include
statement. Linq-to-Entities will allow you to access the properties of the entity without having to include them
var sm = pe.Categories
.Where(c => c.ParentCategory.CategoryName == "Electronics");
sm
will be anIQueryable
of type CategoryIt will contain Categories where its ParentCategory CategoryName is "Electronics"
Each cateogry will have its ParentCategory preloaded for you
var sm = pe.Categories
.Where(c => c.ParentCategory.CategoryName == "Electronics");
This should work as you expect. Adding Include preloads the specified entity.
精彩评论