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

时间:2016-10-14 10:31:33

标签: entity-framework

我是Entity框架的新手,在使用EF和Linq查询方面不是很专业。我有3个表Condition GroupConditionTenantCondition表。加入条件和Condition Group表工作完美,但在条件租户表的加入条件我面临的问题。以下是我的查询。

var qry = (from ConditionGroups in db.ConditionGroups.Include("Conditions")
   where ConditionGroups.IsActive == true
   select new ConditionGroupsEntity
   {
      ConditionGroupGUID = ConditionGroups.ConditionGroupGUID,
      ConditionName = ConditionGroups.ConditionGroupName,
      ConditionList = (from condition in ConditionGroups.Conditions
         join tenantCondition in db.TenantConditions on condition.ConditionID
         equals tenantCondition.ConditionID
         where condition.ConditionTypeID == (int)Enums.ConditionTypes.Allergen
            && (condition.TenantID == null || tenantCondition.TenantID == (usr != null ? usr.TenantID : null)
            && condition.IsPublic == true)
         select new ConditionListEntity
         {
            ConditionGUID = condition.ConditionGUID,
            ConditionName = condition.ConditionName
         }).ToList()
    });
    return qry.ToList();

请建议如何解决此问题。

0 个答案:

没有答案