我有一個Linq到實體查詢與一個子查詢返回一個錯誤,我希望有人能夠幫助我。Linq到子查詢的實體查詢返回錯誤
錯誤消息:
"Unable to create a constant value of type 'SmallBusinessManager.Models.TransactionAllocation'. Only primitive types ('such as Int32, String, and Guid') are supported in this context."
LINQ查詢:
var query = from transactionSelect in smallBusinessManagerDB.Transaction
select new
{
TransactionId = transactionSelect.TransactionId,
TransactionNumber = transactionSelect.TransactionNumber,
Amount = transactionSelect.Amount,
Balance = (from t2 in smallBusinessManagerDB.TransactionAllocation
where t2.InvoiceTransactionId == transactionSelect.TransactionId
group t2 by t2.TransactionAllocationId into g
select g.Sum(p => p.AllocatedAmount))
};
由於提前,
克里斯
你爲什麼不使用關係? – SLaks 2011-05-23 02:31:39
哪些對象或屬性的類型爲'TransactionAllocation'?它只是'smallBusinessManagerDB.TransactionAllocation'? – 2011-05-23 06:10:05