Linq to NHibernate multiple OrderBy calls -


i'm having trouble ordering more 1 field in linq nhibernate query. either know might wrong or if there work around?

code:

iqueryable<agendaitem> items = _agendarepository.getagendaitems(location)    .where(item => item.minutes.contains(query) || item.description.contains(query));  int total = items.count();  var results = items    .orderby(item => item.agenda.date)    .thenby(item => item.outcometype)    .thenby(item => item.outcomenumber)    .skip((page - 1)*pagesize)    .take(pagesize)    .toarray();  return new searchresult(query, total, results); 

i've tried replacing thenby multiple orderby calls. same result. method works great if comment out 2 thenby calls.

error i'm receiving:

     [sqlexception (0x80131904): invalid column name '__hibernate_sort_expr_0____hibernate_sort_expr_1__'.     invalid column name '__hibernate_sort_expr_0____hibernate_sort_expr_1__'.]        system.data.sqlclient.sqlconnection.onerror(sqlexception exception, boolean breakconnection) +1948826        system.data.sqlclient.sqlinternalconnection.onerror(sqlexception exception, boolean breakconnection) +4844747        system.data.sqlclient.tdsparser.throwexceptionandwarning(tdsparserstateobject stateobj) +194        system.data.sqlclient.tdsparser.run(runbehavior runbehavior, sqlcommand cmdhandler, sqldatareader datastream, bulkcopysimpleresultset bulkcopyhandler, tdsparserstateobject stateobj) +2392      [adoexception: not execute query     [ select this_.id id5_2_, this_.agendaid agendaid5_2_, this_.description descript3_5_2_, this_.outcometype outcomet4_5_2_, this_.outcomenumber outcomen5_5_2_, this_.minutes minutes5_2_, agenda1_.id id2_0_, agenda1_.locationid locationid2_0_, agenda1_.date date2_0_, location2_.id id7_1_, location2_.name name7_1_ agendaitem this_ left outer join agenda agenda1_ on this_.agendaid=agenda1_.id left outer join location location2_ on agenda1_.locationid=location2_.id location2_.id = ? , (this_.minutes ? or this_.description ?) order agenda1_.date asc, this_.outcometype asc, this_.outcomenumber asc ]     positional parameters:  #0>1 #0>%core% #0>%core%     [sql: select this_.id id5_2_, this_.agendaid agendaid5_2_, this_.description descript3_5_2_, this_.outcometype outcomet4_5_2_, this_.outcomenumber outcomen5_5_2_, this_.minutes minutes5_2_, agenda1_.id id2_0_, agenda1_.locationid locationid2_0_, agenda1_.date date2_0_, location2_.id id7_1_, location2_.name name7_1_ agendaitem this_ left outer join agenda agenda1_ on this_.agendaid=agenda1_.id left outer join location location2_ on agenda1_.locationid=location2_.id location2_.id = ? , (this_.minutes ? or this_.description ?) order agenda1_.date asc, this_.outcometype asc, this_.outcomenumber asc]]        nhibernate.loader.loader.dolist(isessionimplementor session, queryparameters queryparameters) +258        nhibernate.loader.loader.listignorequerycache(isessionimplementor session, queryparameters queryparameters) +18        nhibernate.loader.loader.list(isessionimplementor session, queryparameters queryparameters, iset`1 queryspaces, itype[] resulttypes) +87        nhibernate.impl.sessionimpl.list(criteriaimpl criteria, ilist results) +342        nhibernate.impl.criteriaimpl.list(ilist results) +41        nhibernate.impl.criteriaimpl.list() +35        nhibernate.linq.criteriaresultreader`1.list() in c:\home\dev\tools\nhibernate\nhibernatecontribsrc\src\nhibernate.linq\src\nhibernate.linq\criteriaresultreader.cs:22        nhibernate.linq.d__0.movenext() in c:\home\dev\tools\nhibernate\nhibernatecontribsrc\src\nhibernate.linq\src\nhibernate.linq\criteriaresultreader.cs:27 

this looks me bug linq nhybernate. 1 possible workaround convert array before sorting. potentially big downside can't limit results using skip() , take() before enumerating, may not sufficient you.

var results = items    .toarray()    .orderby(item => item.agenda.date)    .thenby(item => item.outcometype)    .thenby(item => item.outcomenumber)    .skip((page - 1)*pagesize)    .take(pagesize) 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -