c# - How to add multiple columns inside a single GroupProperty method of Nhibernate Projections Class -
i using visual studio 2008. trying add multiple columns inside single groupproperty method of nhibernate.projections class. but failing required output. tried this.
icriteria criteria = createcriteria("basecriteria"); projectionlist.add(projections.groupproperty( projections.sqlfunction("concat", nhibernateutil.string, projections.property("firstname"), projections.constant(' '), projections.conditional(expression.isnotnull("lastname"), projections.property("lastname"), projections.constant(string.empty)))), "clientname");
generally, aside rowcount
, sum
, groupproperty
can use sqlgroupprojection
var projectionlist = projections.projectionlist() .add(projections.rowcount(), "rowcount") .add(projections.sum("price"), "price") .add(projections.groupproperty("statusid"), "statusid") .add(projections.sqlgroupprojection( "lastname + ' ' + firstname clientname", "lastname + ' ' + firstname", new string[] {"clientname"}, new itype[] {nhibernate.nhibernateutil.string}) , "clientname")
the alias "clientname" repeated few times alias .. not sure omitted, prefer use them all
and shown here nhibernate groupby , sum
that transformed into
public class mydto { public virtual int rowcount { get; set; } public virtual int price { get; set; } // type depends on sum result public virtual int statusid { get; set; } public virtual string name { get; set; } }
with
.setprojection(projectionlist ) .setresulttransformer(transformers.aliastobean<mydto>())
Comments
Post a Comment