我认为我需要这样做,而是使用 LINQ to DataSets,因为“事务”表在 DB2 中并且没有数据上下文。
我在 DataSet 上设置了两个 DataRelations:
1. 将类别(在我的示例中为 ds.tables[0])与产品(ds.tables[1])
相关联 2. 将产品与交易相关联(ds.tables[2])
var query = from x in ds.tables[0].AsEnumerable()
orderby x.Field<int>("Priority")
select new {
Name = x.Field<string>("Text"),
Amount = //maybe using GetChildRows here???
};
我真的不知道该怎么处理金额。提前致谢!