c# - ORDER BY sort key(s) type must be order-comparable -


hope may able help. trying implement jqgrid in asp.net mvc 4 c#. keep getting following error when trying sort column. column field object using foreign key. not sure how code should changed account this. grid sorts correctly fields in model i'm using, not field foreign key. should using viewmodel instead? i'm using code oleg's examples. item.name object , item.name.fullname column i'm trying sort throwing error below. thanks!

the order sort key(s) type must order-comparable. near member access expression, line 6, column 3.

public jsonresult dynamicgriddata(string sidx, string sord, int page, int rows, bool search, string filters)     {         var context = new teamcontext();         var objectcontext = ((iobjectcontextadapter)context).objectcontext;         var set = objectcontext.createobjectset<team>();          var serializer = new javascriptserializer();          filters f = (!search || string.isnullorempty(filters)) ? null : serializer.deserialize<filters>(filters);          objectquery<team> filteredquery =         (f == null ? (objectquery<team>)set : f.filterobjectset((objectquery<team>)set));          filteredquery.mergeoption = mergeoption.notracking; // don't want update data          var totalrecords = filteredquery.count();          var pagedquery = filteredquery.skip("it." + sidx + " " + sord, "@skip",                                             new objectparameter("skip", (page - 1) * rows))                                      .top("@limit", new objectparameter("limit", rows));          // able use tostring() below not exist in linq entity         var querydetails = (from item in pagedquery                             select new { item.teamid, item.year, item.name }).tolist();          return json(new         {             total = (totalrecords + rows - 1) / rows,             page,             records = totalrecords,             rows = (from item in querydetails                     select new[] {                                     item.teamid.tostring(),                                     item.year,                                     item.name.fullname                                 }).tolist()         });     } 

this can fail various reasons:

  • item.name.fullname binary field in database?
  • to access name object through item, lazy loading has enabled. sure is?

anyway using viewmodel data need idea, , way separate data access layer controller.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -