Linq to Sql GroupJoin Paging oddity
Posted
by OllyA
on Stack Overflow
See other posts from Stack Overflow
or by OllyA
Published on 2010-05-12T08:29:33Z
Indexed on
2010/05/12
8:34 UTC
Read the original article
Hit count: 145
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?
© Stack Overflow or respective owner