Question

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>();
Was it helpful?

Solution

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>();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top