c# - how to display orderby descending in LinQ -


i want display order descending in linq web service, , have linq query want order created time.

here web service (getcontent.asmx.cs):

[webmethod] public string[] getcontenttext(string namapage, string tanggalakses, string key) {     string[] ret = new string[4] { null, null, null, null };      if (clsencrypt.decodefrom64(key) == tanggalakses)     {          frontendcontent dt = db.frontendcontent.firstordefault(m => m.namapage.tolower() == namapage.tolower().orderbydescending(m => m.createdtime.tolist());        //list<frontendcontent> dt = db.frontendcontent.orderbydescending(m => new { m.createdtime }).tolist();          if (dt != null)         {             ret[0] = dt.id.tostring();             ret[1] = dt.headertext;             if (string.isnullorempty(ret[1]))             {                 ret[1] = "";             }             ret[2] = dt.subheadertext;             if (string.isnullorempty(ret[1]))             {                 ret[2] = "";             }             ret[3] = dt.contenttext;             if (string.isnullorempty(ret[1]))             {                 ret[3] = "";             }         }     }     return ret; } 

and model here:

using system; using system.linq; using system.componentmodel; using system.componentmodel.dataannotations; using system.web; using system.web.mvc; using system.collections.generic; using system.componentmodel.dataannotations.schema;  namespace penerimaan.models {     public class frontendcontent     {         private modelentities db = new modelentities();          [key]         [displayname("id")]         [scaffoldcolumn(false)]         public int id { get; set; }          [required(errormessage = "nama page required")]         [displayname("nama page")]         [stringlength(110)]         public string namapage { get; set; }          [displayname("header text")]         [stringlength(110)]         public string headertext { get; set; }          [displayname("sub header text")]         [stringlength(110)]         public string subheadertext { get; set; }          [displayname("content")]         [stringlength(10000)]         [allowhtml]         public string contenttext { get; set; }          [displayname("created time")]         public system.datetime? createdtime { get; set; }          [displayname("updated time")]         public system.datetime? updatedtime { get; set; }          [displayname("created by")]         public int? createdby_id { get; set; }          [displayname("updated by")]         public int? updatedby_id { get; set; }           public ienumerable<frontendcontent> selectdata()         {             list<frontendcontent> lst = new list<frontendcontent>();              lst = db.frontendcontent.orderbydescending(m => new { m.namapage }).tolist();             lst = db.frontendcontent.orderbydescending(m => new { m.createdtime }).tolist();              return lst;         }      } } 

but gives error :

'char' not contain definition 'createdtime' , no extension method 'createdtime' accepting first argument of type 'char' found (are missing using directive or assembly reference?)

why using new keyword when ordering? don't need that. should work fine.

list<frontendcontent> lst = new list<frontendcontent>();         lst = db.frontendcontent.orderbydescending(m => m.namapage).tolist();         lst = db.frontendcontent.orderbydescending(m => m.createdtime).tolist();         return lst; 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -