EasyObject Sort with datetime function

It is pretty easy to sort data with EasyObject:
 

obj.Query.AddOrderBy(FishSamplingSchema.MyColumnA, NCI.EasyObjects.WhereParameter.Dir.ASC);

It takes some string manipulation to work with SQL functions if we use obj.Sort method:

Here is an example for working datetime function:

obj.Sort =

String.Format(@"DATEADD(day, DATEDIFF(day,0, {0}) ,0) DESC", FishSamplingSchema.myDateTimeColumn);

 

The whole set looks like:

mySampling obj = new mySampling();

obj.Sort =

String.Format(@"DATEADD(day, DATEDIFF(day,0, {0}) ,0) DESC", FishSamplingSchema.myDateTimeColumn);

obj.Query.AddOrderBy(FishSamplingSchema.myColumnA, NCI.EasyObjects.WhereParameter.Dir.ASC);

obj.Where.SurveyVisitID.Value = someValue;

obj.Query.Load();

 

Advertisements