开发者

Linq to Sql GroupJoin Paging oddity

开发者 https://www.devze.com 2022-12-30 13:01 出处:网络
I have noticed a strange Sql Translation in a LinqToSql Query I was trying to optimise. If I execute the following

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

精彩评论

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