views:

23

answers:

0

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?