How to sort on multiple fields in data class


i have class datajoindatasummary.  i want able sort lotnumber, datetime, absorbance and/or materialid fields.  it works lotnumber can't figure out how alter code allow sort other fields.  the datetime field nullable.  any responses appreciated.

thanks.

rob

using system;  using system.collections.generic;  using system.linq;  using system.text;  using system.threading.tasks;    namespace phoenix_fastscreen.dataaccess.entities  {      class datajoindatasummary : icomparable<datajoindatasummary>      {          public string materialid          {              get;              set;          }          public string lotnumber          {              get;              set;          }          public string panelformat          {              get;              set;          }          public int repeat          {              get;              set;          }          public decimal? absorbance          {              get;              set;          }          public datetime? datetime          {              get;              set;          }          public string welllocation          {              get;              set;          }          public string paneltype          {              get;              set;          }            public datajoindatasummary(string materialid, string lotnumber, string panelformat, int repeat, decimal? absorbance, datetime? datetime, string welllocation, string paneltype)          {              this.materialid = materialid;              this.lotnumber = lotnumber;              this.panelformat = panelformat;              this.repeat = repeat;              this.absorbance = absorbance;              this.datetime = datetime;              this.welllocation = welllocation;              this.paneltype = paneltype;          }            public int compareto(datajoindatasummary other)          {               return this.lotnumber.compareto(other.lotnumber);                      //    //return this.datetime.tostring().compareto(other.datetime.tostring());          }    		  	//i have code works sorting lotnumber, can't sort work datajoindatasummariescollectall.datetime field            datajoindatasummariescollectall.sort(delegate(datajoindatasummary datajoindatasummary1, datajoindatasummary datajoindatasummary2)          {              return datajoindatasummary1.lotnumber.compareto(datajoindatasummary2.lotnumber);          });    		

if objects in list<t>, can use linq sort objects property values.

http://www.tutorialsteacher.com/linq/linq-sorting-operators-orderby-orderbydescending



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts

How to Share webservice object to all user