var Query = dbContext.GetUserDetailsForAutoMail().AsEnumerable().ToList();
dt1 = Query.CopyToDataTable();
I want to convert a List
to DataTable
using LINQ without looping.
In the above code GetUserDetailsForAutoMail()
is storedprocedure, the result can be stored in an query, after it can be convert into a DataTable
but it throws an error like
Error 1 The type 'AutoSendigEmail.GetUserDetailsForAutoMail_Result' cannot be used as type parameter 'T' in the generic type or method 'System.Data.DataTableExtensions.CopyToDataTable(System.Collections.Generic.IEnumerable)'. There is no implicit reference conversion from 'AutoSendigEmail.GetUserDetailsForAutoMail_Result' to 'System.Data.DataRow'. D:\Deva\AutoSendigEmail\AutoSendigEmail\Service1.cs 68 23 AutoSendigEmail