Tomek
Tomek

Reputation: 9

Linq to nhibernate question

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

Upvotes: 0

Views: 164

Answers (1)

Paco
Paco

Reputation: 8381

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

Upvotes: 1

Related Questions