InspectionDataContext dataContext = new InspectionDataContext();
var query = from records in dataContext.Inspections select records;
DataTable dTable = objectOfCommonClass.GetDataTable(dataContext, query);
public DataTable GetDataTable(InspectionDataContext dc, object query)
{
DataTable dataTable = new DataTable();
IDbCommand cmd = dc.GetCommand(query as IQueryable);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = (SqlCommand)cmd;
cmd.Connection.Open();
adapter.FillSchema(dataTable, SchemaType.Source);
adapter.Fill(dataTable);
cmd.Connection.Close();
return dataTable;
}
0 comments:
Post a Comment