Pergunta

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>();
Foi útil?

Solução

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>();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top