开发者

Linq to Sql GroupJoin Paging oddity

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜