我有一个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