Convert SQL with 'is in' to QueryOver()

本文关键字:QueryOver to in SQL Convert is with | 更新日期: 2023-09-27 17:49:30

我需要下面的查询做与NHibernate QueryOver。但是我对这个列表有问题。

select * from contact where CountryId = 'xxx' and contactttypeid in ('aaa', 'bbb')

value是Guid的。我有一个列表(),其中包含的Guid的ContactTypeId (contactTypes)

我已经试过了,但是这行不通:

                var query = contactRepository.GetAllOver()
                    .Where(x => x.Country != null && x.Country.Id == countryId)
                    .WhereRestrictionOn(x => x.ContactType.Id).IsInG(contactTypes);

我希望有人能给我一个提示如何用QueryOver写这个

Convert SQL with 'is in' to QueryOver()

try this

var query = contactRepository.GetAllOver()
                .Where(x => x.Country != null && x.Country.Id == countryId)
                .And(Restrictions.On(c => c.ID).IsIn(contactTypes)