Tengo una tabla GL que contiene GLCode. Necesito obtener una lista de GLCodes únicos, pero obtener todas las otras columnas. El siguiente SQL produce los resultados que quiero.NHibernate: Obtenga resultados distintos basados en una columna, pero recupere todas las columnas
select * from GL where GLId in (select Min(GLId) from GL group by GLCode)
¿Hay alguna manera de hacerlo con la API de Criteria?
Ésta es mi mejor intento:
var subQuery = DetachedCriteria.For<GL>();
subQuery
.SetProjection(Projections.Property("GLCode"))
.SetResultTransformer(new DistinctRootEntityResultTransformer());
return (List<GL>)currentSession
.CreateCriteria(typeof(GL))
.Add(Subqueries.PropertyIn("GLCode", subQuery))
.List<GL>();
estoy también enfrenta el mismo problema. ¿Alguna ayuda? – Bipul