我是linq的新手,所以请给我链接或编写一步一步的程序来填写linq中的数据表
代码
var Sql = from t1 in pitbull.ACC_APP1_QuickViews.AsEnumerable()
join t2 in pitbull.OCC_VehicleGroups.AsEnumerable()
on t1.VehicleId equals t2.VehicleID
select new
{
t1.Lat,
t1.Lon,
t1.Timestamp_GPS,
t1.Speed,
t1.Location,
t1.Status,
t1.VehicleRegNo,
t1.VehicleId,
t2.VGID,
t2.VGName
};
DataTable dt = new DataTable();enter code here
dt=Sql.copytodatatable();
//copy to datatable not support.Improve question Permalink
这是因为您正在使用select new{ }
创建一个匿名类型来保存字段对象。试试这个:
var Sql = from t1 in pitbull.ACC_APP1_QuickViews.AsEnumerable()
join t2 in pitbull.OCC_VehicleGroups.AsEnumerable()
on t1.VehicleId equals t2.VehicleID
select t2;
DataTable dt = Sql.copytodatatable();