1
假設我必須實體名爲SalesOrders的POCO實體和從名爲SalesOrderLines的SQL數據庫生成的常規實體。我想創建一個從SalesOrders到SalesOrderLines的關聯,如下面的代碼所示,但是我一直在代碼下面看到異常。有誰知道這是否可能?是否可以將POCO實體與標準實體相關聯?
[DataServiceKey("SalesOrderNumber")]
public class SalesOrder
{
[Key]
public int SalesOrderNumber { get; set; }
public string StockCode { get; set; }
public string Description { get; set; }
[Include]
[Association("SalesOrder_SalesOrderLine", "SalesOrderNumber", "SalesOrderNumber")]
public IQueryable<SalesOrderLine> SalesOrderLines
{
get
{
SalesOrderLineEntities oSalesOrderLineEntities = new SalesOrderLineEntities();
var soLines = from line in oSalesOrderLineEntities.SalesOrderLines
where line.OrderNumber == SalesOrderNumber.ToString() &&
line.StockCode == StockCode
select line;
return soLines;
}
set
{
}
}
}
'的類型 'ServiceName.NameSpace.SalesOrder「屬性' SalesOrderLines' 是不是有效的屬性。不支持類型爲基元或複合類型集合的屬性。'