Convert var to DataTable
- by cre-johnny07
I have var item which I want to convert in to a Datatable.
How can I do this.
var items =  (from myObj in this.Context.Orders
                     group myObj by myObj.OrderDate.ToString("yyyy-mm")
                     into ymGroup
                     select new { Date = ymGroup.Key, Start = ymGroup.Min(c => c.OrderId), End = ymGroup.Max(c => c.OrderId) });
I need to convert the items into a DataTable. I don't want to use any foreach loop.
How can I do this.?