无法创建类型的常量值。在此上下文中仅支持基元类型或枚举类型

时间:2013-11-18 14:32:16

标签: c# linq entity-framework

为什么我会收到错误“无法创建类型为'PhilpostDB.POCO.MakerCheckerService.RouteAgentsConfigsChecker'的常量值。在此上下文中仅支持基本类型。”当我尝试枚举以下Linq查询?

所以我有这段代码:

public List<CheckerViewModelPhilpostDB> getAllCheckerTransactions(string status)
{
List<CheckerViewModelPhilpostDB> _Return = new List<CheckerViewModelPhilpostDB>();
if (status == "Approved")
        {
            _Return = (from a in _UnitOfWorkBase.RouteAgentsConfigsMaker.dbSet
                       from b in _UnitOfWorkBase.RouteAgentsConfigsChecker.dbSet
                       where a.Id == b.fk_RouteAgentsConfigsMaker && b.status == 1
                       select new CheckerViewModelPhilpostDB()
                       {
                           CashAmount = a.CashAmount,
                           CurrencyType = a.CurrencyType,
                           LogDate = a.LogDate,
                           MakerIntegrationSystemId = a.fk_MakerIntegrationSystemId,
                           CheckDate = b.LogDate,
                           Status = b.status,
                           RejectReason = b.Reason
                       }).ToList<CheckerViewModelPhilpostDB>();
        }
        else if (status == "Rejected")
        {
            _Return = (from a in _UnitOfWorkBase.RouteAgentsConfigsMaker.dbSet
                       from b in _UnitOfWorkBase.RouteAgentsConfigsChecker.dbSet
                       where a.Id == b.fk_RouteAgentsConfigsMaker && b.status == 0
                       select new CheckerViewModelPhilpostDB()
                       {
                           CashAmount = a.CashAmount,
                           CurrencyType = a.CurrencyType,
                           LogDate = a.LogDate,
                           MakerIntegrationSystemId = a.fk_MakerIntegrationSystemId,
                           CheckDate = b.LogDate,
                           Status = b.status,
                           RejectReason = b.Reason
                       }).ToList<CheckerViewModelPhilpostDB>();
        }
        return _Return;

    }

不幸的是,它抛出了这个错误:

Unable to create a constant value of type    'PhilpostDB.POCO.MakerCheckerService.RouteAgentsConfigsChecker'.
 Only primitive types or enumeration types are supported in this context.

0 个答案:

没有答案