我有两个对象RR和TT,RR.TT_Id(FK) - > TT.Id(PK)
我想根据以下查询从RR中过滤记录:
SELECT RR.* FROM RR
LEFT OUTER JOIN TT ON RR.TT_Id = TT.Id
WHERE TT.Type <> :type ")
.SetEnum("type", T_TypeEnum.XX)
所以,添加了如下标准:
List<RR> lstReportRequests = new List<RR>();
var subQuery = DetachedCriteria.For<TT>()
.Add(Restrictions.Not(Restrictions.Eq("Type", T_TypeEnum.XX)))
.SetProjection(Projections.Id());
IList<ICriterion> criterions = new List<ICriterion>();
criterions.Add(Restrictions.Eq(RefHelper.ToString<RR>(x => x.OfficeId), officeId));
criterions.Add(Restrictions.In("TT_Id", subQuery)); //*....error - need a collection for second argument*
IMultiCriteria c = session.CreateMultiCriteria();
c.ApplyStrategy<RR>(criterions, strategy.StrategyElements);
但是在尝试将DetachedCriterion添加到IMultiCriteria时出现错误 -
无法从'NHibernate.Criterion.DetachedCriteria'转换为'System.Collections.ICollection'
请指导如何解决以上错误?
谢谢!