DataTable to IQueryable<T>
- When we need store data which are in DataTable rather as objects in IQuerable<T>, we can use code as below.
DataTable dataTable = GetDataTable(); var importdata = from row in dataTable.AsEnumerable() select new ImportRow() { GroupExtID = row.Field<int>(SubjectsImportStructure.PID), ExtID = row.Field<int>(SubjectsImportStructure.ID), Condition = row.Field<int>(SubjectsImportStructure.Condition), IC = row.Field<string>(SubjectsImportStructure.IC), RC = row.Field<string>(SubjectsImportStructure.RC), }; IQueryable<IImportRow> data = importdata as IQueryable<IImportRow>;