Thursday, July 9, 2009

Linq saves the day when sorting ui lists...

Have you ever been in a situation where you have to write elaborate code to order a list of something by date and some of the dates are null? Well worry not, Linq is here to rescue.


This list contains an object that has a created date. The created date did not exist in the legacy database, and was therefore null. Unfortunately using Linq from o in list orderby o.CreatedDate descending didnt work.


After some investigation, (and whining about having to do lots of work for simple gain), I discovered Union in Linq. Sure enough this solved the problem and i could bind to the repeater with the correct order.

No comments:

Post a Comment