2011-04-07 73 views
1

我需要使用NHibernate QueryOver進行查詢。但我在列表中遇到問題。將SQL轉換爲QueryOver()

SELECT * FROM接觸其中CountryId = 'xxx' 的和在ContactTypeId( 'AAA', 'BBB')

的值是的Guid的。我有

我已經試過其中包含GUID對ContactTypeId(contactTypes)的列表() - 但是這是行不通的:

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

我希望有人能夠給我一個TIPP如何與QueryOver寫。

+0

如何AndRestrictionOn(P => p.ContactType.Id).IsInG (GuidList)還有什麼是你所得到的錯誤? – WorldIsRound 2011-04-07 21:20:32

回答

2

試試這個

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

我希望這是有幫助的。

+0

我與 VAR查詢現在解決它= contactRepository.GetAllOver() 。凡(X => x.Country!= NULL && x.Country.Id == countryId) .AndRestrictionsOn(C => c.ID) .IsIn(contactTypes) 我想,這就像你的解決方案 – BennoDual 2011-04-08 21:09:38

+0

@ t.kehl一樣:是的,這是相同的! – Faber 2011-04-08 22:08:09