views:

35

answers:

1

Hi,

I'm trying to create a query using linq 2 nhibernate which generate a sql like:

select * from table
where id in (1, 2, 3, 4)

At the moment I have this code:

var vouchers = Session.Linq<Voucher>()
                                  .Where(x => campaignIds.Contains(x.VoucherGroup.Campaign.Id))
                                  .ToArray();

The campaignIds is array of 'long' variables.

But this code will just download all the vouchers and iterate through them to find only those with specific campaignId.

I could of course iterate through the campaign Ids and call the database for each campaign Id and use the union operator but I wonder if there is some more elegant way of doing it.

Thanks

+1  A: 

You have found a bug. I use similar queries with the linq provider in the trunk and I don't have problems with it.

Paco