How to populate DataTable with anonymous LINQ result

前端 未结 3 418
误落风尘
误落风尘 2020-12-21 00:49

I have the following LINQ query:

var timesheets = from timesheet in entities.Timesheets
    join timesheetTask in entities.Timesheet_Task on timesheet.Id e         


        
3条回答
  •  渐次进展
    2020-12-21 01:27

    I'm using FastMember for this purpose. It uses IL instead of reflection (much faster) to iterate over all of the property and field values automatically. Code sample from the site:

    IEnumerable data = ...
    var table = new DataTable();
    using(var reader = ObjectReader.Create(data))
    {
        table.Load(reader);
    }
    

提交回复
热议问题