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
您可以使用contains进行以下操作:
.Where(x => ListOfSubsetCodes.Contains (x.Code))
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.