ICriteria and Linq to NHibernate together
-
27-05-2021 - |
문제
How can I create one query using both ICriteria and Linq? Example:
var q = Session
.Query<T>()
.Where(x.Id == 1)
.ToCriteria()
.Add(Restrictions.Eq("Title", "Ayende @ Rahien"))
.List<T>();
해결책
I think, you should use QueryOver for it:
var q = Session
.QueryOver<T>()
.Where(x.Id == 1)
.Add(Restrictions.Eq(Projections.Property<T>(x.Title), "Ayende @ Rahien"))
.List<T>();
제휴하지 않습니다 StackOverflow