c# - how to use eager loading without string for related entities? -
i use eager loading load related entities , see this page:
in example can see there 2 ways related entities:
var princesses1 = context.princesses .include(p => p.unicorns) .tolist(); var princesses1 = context.princesses .include("unicorns") .tolist();
the first way use lambda expression (i think correct name that, if not, correct me), , second way use string name of related entity.
in case, can use second, because in firt way, when can't property of related entity in lambda expression. use code:
iqueryable<customers> myquery; myquery = mycontext.customers.include("orders");
but if try use second way:
iqueryable<customers> myquery; myquery = mycontext.customers.include(c=>c.?????);
i can't select orders property.
why?
add top of file:
using system.data.entity;
this includes reference dbextensions class provides include extension method.
Comments
Post a Comment