1

I want to collect all rows and pass it to datatable. My linq query:

var queryAll = from all in db.tblMake select all ;
DataTable dt = new DataTable();

How can i pass the queryAll into datatable dt?

If i try :

 IEnumerable<DataRow> queryAll = from all in db.tblMake.AsEnumerable() select all;

comes with error:

 Cannot Implicitely Convert type 'System.Collection.Generic.IEnumerable<Workshop2s.Models.tblMake>' to 'System.Collection.Generic.IEnumerable<System.Data.DataRow>'
black
  • 153
  • 1
  • 2
  • 13
  • http://stackoverflow.com/questions/4460654/best-practice-convert-linq-query-result-to-a-datatable-without-looping – Donal Aug 18 '14 at 09:55
  • Thnx for response. But if i try like this IEnumerable queryAll = from all in db.tblMake.AsEnumerable() select all; comes with the error 'Cannot Implicitely Convert type 'System.Collection.Generic.IEnumerable to 'System.Collection.Generic.IEnumerable' – black Aug 18 '14 at 10:16
  • have you read this: http://msdn.microsoft.com/en-us/library/bb386921.aspx – Donal Aug 18 '14 at 10:24

0 Answers0