在SQL ease中:
where (Id1 = @iX and Id2 = @iY) OR (id1 is null AND Id2 is null)
In(sudo / failed)nHibernate:
where (c => c.Id1 == iX AND c.Id2 == iY) OR (c => c.Id1 == null AND c.Id2 == null)
所有有用的建议表示赞赏。
答案 0 :(得分:0)
使用标准:
var r = ses.CreateCriteria<myT>()
.Add(Restrictions.Or(
Restrictions.And(Restrictions.Where<myT>((c) => c.Id1 == iX)
, Restrictions.Where<myT>((c) => c.Id2 == iY)
)
, Restrictions.And(Restrictions.Where<myT>((c) => c.Id1 == null)
, Restrictions.Where<myT>((c) => c.Id2 == null)
)
))
.List<myT>();
网是合理的:
WHERE ((this_.Id1 = @p0 and this_.Id2 = @p1) or (this_.Id1 is null and this_.Id2 is null))
其中@ p0 = @iX和@ p1 = @iY