Convert SQL with 'is in' to QueryOver()
I n开发者_JAVA技巧eed the fallowing Query do with NHibernate QueryOver. But I have Problems with the List.
select * from contact where CountryId = 'xxx' and ContactTypeId in ('aaa', 'bbb')
The Values are Guid's. I have a List() which contains the Guid's for ContactTypeId (contactTypes)
I have tried - but this will not work:
var query = contactRepository.GetAllOver()
.Where(x => x.Country != null && x.Country.Id == countryId)
.WhereRestrictionOn(x => x.ContactType.Id).IsInG(contactTypes);
I hope someone could give me a tipp how to write this with QueryOver.
try this
var query = contactRepository.GetAllOver()
.Where(x => x.Country != null && x.Country.Id == countryId)
.And(Restrictions.On(c => c.ID).IsIn(contactTypes)
I hope it's helpful.
精彩评论