Domanda

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>();
È stato utile?

Soluzione

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>();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top