一对多数据查询 #1036
Unanswered
ZhangYiQiu
asked this question in
Q&A
一对多数据查询
#1036
Replies: 2 comments 1 reply
-
导航,了解一下 https://github.com/dotnetcore/FreeSql/wiki/%e5%ae%9e%e4%bd%93%e5%85%b3%e7%b3%bb |
Beta Was this translation helpful? Give feedback.
1 reply
-
很遗憾,因为 FreeSql 没有类似 EF 的 GroupJoin 的用法,所以如果要达到这个目的,应该需要自己在内存中处理数据。 freeSql.Select<TableA, TableA_TableB_Rel, TableB>()
.InnerJoin((a, rel, b) => a.Id == rel.TableA_Id)
.InnerJoin((a, rel, b) => rel.TableB_Id == b.Id)
.ToList((a, rel, b) => new { a.Id, bId = b.Id, name = b.Name })
.GroupBy(a => a.Id)
.Select(grouping => new TableA
{
Id = grouping.Key,
Items = grouping.Select(b => new TableB { Id = b.bId, Name = b.name }).ToList()
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
数据库实体如下
列表如下
在不增减字段的情况下,我该如何在查询TableA的时候带出Items的数据
Beta Was this translation helpful? Give feedback.
All reactions