DbSet.Include运算符,用于ef7接受字符串路径

编程入门 行业动态 更新时间:2024-10-08 14:48:27
本文介绍了DbSet.Include运算符,用于ef7接受字符串路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

EF6具有DbSet.Include的重载,它接受一个字符串参数,该字符串参数表示以点分隔的相关对象列表,以返回查询结果。这对于在多级对象图中快速加载实体很有用。例如:

EF6 has an overload of DbSet.Include which accepts a string parameter representing a dot-separated list of related objects to return in the query results. It is useful for eager-loading entities in a multi-level object graph. For example:

var order = await _dbContext.Orders .Include(o => o.Customer) .Include("OrderDetails.Product") // dot-delimited path .SingleOrDefaultAsync(o => o.OrderId == id);

这将返回两个相关的订单明细,并通过生成一条SQL语句填充每个明细的Product属性。联接OrderDetail和Product表。

This will return both related order details and populate the Product property of each detail by generating a SQL statement that joins OrderDetail and Product tables.

我正在寻找一种使用EF7的方法,但是我没有看到 DbSet.Include 的重载。 >接受 string 路径参数。 EF7是否提供与EF6 API相同的结果?

I am looking a way to do this with EF7, but I don't see an overload of DbSet.Include which accepts a string path parameter. Does EF7 provide a way to achieve the same result as the EF6 API?

PS。我只是注意到问题#1151 已打开,看来它可以解决我的问题。

PS. I just noticed issue #1151 is open, and it looks like it may address my question.

推荐答案

您正确地认为#1151 正在跟踪这种情况。还有一些设计会议记录,总结了将在EF7中使用的API- github/aspnet/EntityFramework/wiki/Design-Meeting-Notes:-January-8,-2015 。

You are correct that #1151 is tracking this scenario. There are also some design meeting notes that summarize the API that will be available in EF7 - github/aspnet/EntityFramework/wiki/Design-Meeting-Notes:-January-8,-2015.

更多推荐

DbSet.Include运算符,用于ef7接受字符串路径

本文发布于:2023-11-15 06:26:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1591950.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   路径   运算符   DbSet   Include

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!