2

我在 mvc4 应用程序中有一个 linq 查询,它给了我错误

'无法创建'CMMIS.Domain.tblCustomer' 类型的常量值。在此上下文中仅支持原始类型或枚举类型。

. 任何帮助都是可观的。提前致谢。以下是我的代码-

public List<tblEquipment> getEquipmentByLaneAndContractId(string Lane, string contractId)
{
        var query = (from c in _equipmentRepository.Table
                     from p in _customerRepository.Table
                     from q in _contractRepository.Table
                     where c.EquipLane == Lane && c.EquipActive == true && c.EquipCustID == p.CustID
                     && p.CustContractID == q.ContractID && q.ContractID == contractId
                     select c).ToList();

        return query;
}
4

1 回答 1

0

我认为这样的事情应该有效。这是假设实体表通过外键关系相互链接。

public List<tblEquipment> getEquipmentByLaneAndContractId(string Lane, string contractId)
{
    var query =  (from c in _equipmentRepository.Table
                  where c.EquipLane == Lane &&
                        c.EquipActive == true &&
                        c.EquipCust.CustContractID == contractId
                  select c).ToList();

    return query;
}
于 2013-05-15T12:10:55.493 回答