Asp.net mvc 无法创建“ABC”类型的常量值。在此上下文中仅支持基元类型或枚举类型
我在mvc4应用程序中有一个linq查询,它给了我一个错误 '无法创建'CMMIS.Domain.tblCustomer'类型的常量值'。 此类型中仅支持基元类型或枚举类型 上下文。” 。任何帮助都是值得的。提前谢谢。下面是我的代码-Asp.net mvc 无法创建“ABC”类型的常量值。在此上下文中仅支持基元类型或枚举类型,asp.net-mvc,c#-4.0,asp.net-mvc-4,linq-to-entities,entity-framework-4.1,Asp.net Mvc,C# 4.0,Asp.net Mvc 4,Linq To Entities,Entity Framework 4.1,我在mvc4应用程序中有一个linq查询,它给了我一个错误 '无法创建'CMMIS.Domain.tblCustomer'类型的常量值'。 此类型中仅支持基元类型或枚举类型 上下文。” 。任何帮助都是值得的。提前谢谢。下面是我的代码- public List<tblEquipment> getEquipmentByLaneAndContractId(string Lane, string contractId) { var query = (from c in _eq
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;
}
我想这样的办法应该行得通。这是假设实体表通过外键关系相互链接
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;
}
_equipmentRepository.Table的类型是什么?看看