How can i use a orderby clause using a DateTime field ignoring the year?
Is that possible?
Thanks
2 Answers, 1 is accepted
0
Accepted
Dimitar Tachev
Telerik team
answered on 16 Nov 2012, 04:40 PM
Hi Alexandre,
In order to use the OrderBy clause on a DateTime field ignoring the year I suggest you to base your query on the following code snippet which is retrieving data from the Orders table of the Northwind database.
...
using (YourContextName db = new YourContextName())
{
var orderByDateTimeWithoutYear = db.Orders
.Where(x => x.OrderDate.HasValue)
.OrderBy(x => x.OrderDate.Value.Month)
.ThenBy(x => x.OrderDate.Value.Day);
...
}
...
If you want to become more familiar with the LINQ capabilities of OpenAccess ORM you can download our SDK and look at our Linq 101 sample.
I hope this helps.
Regards,
Dimitar Tachev
the Telerik team
Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.