【发布时间】:2010-09-08 11:34:32
【问题描述】:
我在 Accounts 和 PaymentSystems 之间存在多对多关系。我想列出所有尚未分配给帐户的 PaymentSystems。为此,我尝试使用以下 LINQ to Entities 查询:
PaymentGatewayEntities pge = new PaymentGatewayEntities();
Account account = pge.Accounts.Single(item => item.id == accountId);
var paymentSystems = pge.PaymentSystems.Except(account.PaymentSystems);
但是,在尝试显示结果时出现以下异常:“System.NotSupportedException:无法创建类型为“MyNamespace.Models.PaymentSystem”的常量值。只有原始类型(例如 Int32、String 和Guid') 在这种情况下得到支持。”我究竟做错了什么?我正在使用 EF4。
UPD: var paymentSystems = pge.PaymentSystems.Where(item => !item.Accounts.Contains(account)) 也会导致相同的异常。
【问题讨论】:
标签: linq-to-entities entity-framework-4