Reputation: 761
When using QueryOver, I normally write a Where clause where the field exactly matches a value:
var subset = _session.QueryOver<ProviderOrganisation>()
.Where(x => x.Type == "Hospital")
.List<ProviderOrganisation>();
But now I want to match the field against a list of values, so in SQL something like a "Where x is in ():"
var subset = _session.QueryOver<ProviderOrganisation>()
.Where(x => x.Code is In (ListOfSubsetCodes))
.List<ProviderOrganisation>();
How do I do that please?
Thanks
Upvotes: 1
Views: 175
Reputation: 1583
You've used QueryOver, and another way of doing this:
.WhereRestrictionOn(x => x.Code).IsIn(ListOfSubsetCodes)
I think x => ListOfSubsetCodes.Contains()
will work well for LINQ, but not for QueryOver.
Upvotes: 4
Reputation: 27944
You can use contains to do a in:
.Where(x => ListOfSubsetCodes.Contains (x.Code))
Upvotes: 4