我正在尝试从多个表中恢复和显示数据。o 我做了一个这样的多重连接:
var prod = from product in context.PRODUCT
join islocated in context.ISAUDITEDIN on product.PRODUCT_ID equals islocated.PRODUCT_ID
join location in context.LOCATION on islocated.LOCATION_ID equals location.LOCATION_ID
orderby location.LOCATION_ID
group new
{
Location_ID = location.LOCATION_ID,
Product_ID = product.PRODUCT_ID
} by location.LOCATION_ID into locat
select new {
Location_ID = locat.Key,
Product = locat
};
其中 context 是从 Web 服务调用产生的 OData。该链接有效:当我进行简单选择时,我能够恢复数据。然后,我想显示结果中的数据。所以我创建了一个字典:
Dictionary<string,List<ProductModel>> dict = new Dictionary<string,List<ProductModel>>();
foreach (var locat in prod) {
List<ProdctModel> products = new List<ProductModel>();
foreach (var p in locat.Product)
{
products.Add(new ProductModel(p.Location_ID, p.Product_ID));
}
dict.Add(locat.Location_ID.ToString(), products);
}
ProductModel 是一个像这样的简单类:
public class ProdctModel
{
public int locationID{get; set;}
public int productID{get; set;}
public ProdctModel(int location_ID, int product_ID)
{
this.locationID = location_ID;
this.productID = product_ID;
}
}
但是当我运行它时,我有以下内容:
“the method join is not supported”
Ligne 131 : Dictionary<string,List<ProdctModel>> dict = new Dictionary<string,List<ProdctModel>>();
Ligne 132 : foreach (var locat in prod) {
如何解决?我通过使用方法 .Expand() 而不是 join 看到了一些东西,但我不知道如何使用它:你能帮我吗?
谢谢!