加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 具有多个引用的Entity Framework LoadProperty

发布时间:2020-12-15 17:16:47 所属栏目:百科 来源:网络整理
导读:使用实体框架,您可以执行类似的操作,以使用查询加载多个引用的对象. var Customer = context.Customers.Include(x=x.Orders.Select(y=y.Items)); 看起来我不能用LoadProperty方法做同样的事情.当我已经有一个对象并且我需要加载一些参考数据时,我使用LoadPro
使用实体框架,您可以执行类似的操作,以使用查询加载多个引用的对象.

var Customer = context.Customers.Include(x=>x.Orders.Select(y=>y.Items));

看起来我不能用LoadProperty方法做同样的事情.当我已经有一个对象并且我需要加载一些参考数据时,我使用LoadProperty.

context.LoadProperty(Customer,x=>x.Orders);

这样可行.但这会引发错误..

context.LoadProperty(Customer,x=>x.Orders.Select(y=>y.Items));

这也是……

context.LoadProperty(Customer.Orders,x=>x.Items);

这是两种情况的例外……

The selector expression for
LoadProperty must be a MemberAccess
for the property.

解决方法

No LoadProperty不允许这样做.您可以尝试使用 another question中描述的方法.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读