Hi
How to store the results of Linq Query in Datatable
List Result = (from t in context.View_SessionBookPlanningRecommendations
orderby t.StudentID
where StudentCollection.Contains(t.StudentID.ToString())
select t).ToList();
Thanks
Naimish MakwanaPosted Apr 26, 2023, 5:24 AM
To store the results of a LINQ query in a DataTable, you can use the CopyToDataTable() method. Here's how you can modify your code to do so:
The
CopyToDataTable()method creates a new DataTable based on the results of the LINQ query. If the query returns no results, an empty DataTable is created. You can then use thedtDataTable to perform further operations, such as displaying the results in a data grid or exporting them to a file.Thanks
Amit MohantyPosted Apr 26, 2023, 4:24 AM