Saturday, 8 June 2013

Take() method not available for my LINQ query, Any reason why?

Take() method not available for my LINQ query, Any reason why?

I want to retrieve only top 100 items from the DataTable object. I have done this before on the generic lists using Take() method, but not sure why it's not available for this one.
Below is my LINQ query:
    IEnumerable<DataRow> query = (from task in dtTasks.AsEnumerable()
                                  where  task.Field<DateTime>("EstimatedStartTimeStamp") <= DateTime.Parse(DateTime.Today.Date.AddDays(1).ToString("MM/dd/yyyy"))
                                 orderby task.Field<DateTime>("Status")
                                 select task);

    DataTable boundTable = query.CopyToDataTable<DataRow>();
The problem is when I try to use Take() method, it just doesn`t show up in the intellisense. It shows other methods like OrderBy/OrderByDescending.
Thanks for your time!

No comments:

Post a Comment