DataTable , LINQ to Sql, , IQueryable DataTable:
public static DataTable AsDataTable(this IQueryable value, DataTable table)
{
var reader = value.GetEnumerator();
while (reader.MoveNext())
{
var record = (Customer)reader.Current;
table.Rows.Add(record.CustomerID, record.City);
}
return table;
}
, - TEntity:
[Table(Name = "Customers")]
public class Customer
{
[Column(IsPrimaryKey = true)]
public string CustomerID;
[Column]
public string City;
}
, DataTable Customer. , , :
public DataTable GetSchema(params string[] columns)
{
string col_list;
if (columns.Length == 0)
col_list = "*";
else
col_list = String.Join(", ", columns);
return Provider.QueryAsDataTable(string.Format("select top 0 {0} from customers", col_list));
}
, DataGridView:
dgridRO.DataSource = new DataView(rows.AsDataTable(dmap.GetSchema("CustomerID", "City")));
**
ID10TException:
**
IQueryable DataTable, DataView DataGridView. , , .