Wednesday, May 30, 2012

Cast<DataRow>

the following code will load top 5 rows Order in ascending row filter rows based on current date 

   1: return rows.Count() > 0 ? dt.Rows.Cast<DataRow>()
   2: .OrderByDescending(r => r["StartDate"]).
   3: Where(j => (DateTime)j["StartDate"] >= DateTime.Now).
   4: Take(5).CopyToDataTable() ;

No comments: