Linq to Sql GroupJoin 分页怪事
我注意到我试图优化的 LinqToSql 查询中有一个奇怪的 Sql 翻译。
如果我执行以下命令,
Recipients.GroupJoin(
RecipientAttributes,
x => x.Recipient_Id,
y => y.Recipient_Id,
(x,y) => new {Recipient = x, Attributes = y})
.Skip(1)
.Take(1000)
它将按预期在单个查询中执行。
但是,
Recipients.GroupJoin(
RecipientAttributes,
x => x.Recipient_Id,
y => y.Recipient_Id,
(x,y) => new {Recipient = x, Attributes = y})
.Skip(0)
.Take(1000)
针对每个属性选择在单独的查询中执行。
删除 Skip(0) 也没有什么区别。
谁能解释一下这一点,我可以做些什么来让第一页查询在单个 sql 语句中执行?
I have noticed a strange Sql Translation in a LinqToSql Query I was trying to optimise.
If I execute the following
Recipients.GroupJoin(
RecipientAttributes,
x => x.Recipient_Id,
y => y.Recipient_Id,
(x,y) => new {Recipient = x, Attributes = y})
.Skip(1)
.Take(1000)
It executes in a single query as expected.
However
Recipients.GroupJoin(
RecipientAttributes,
x => x.Recipient_Id,
y => y.Recipient_Id,
(x,y) => new {Recipient = x, Attributes = y})
.Skip(0)
.Take(1000)
executes in a separate query for each Attributes selection.
Removing the Skip(0) makes no difference either.
Can anyone explain this and is there something I can do to get the first page query executing in a single sql statement?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论