• 指定类型的成员XX”不支持实体LINQ。只有初始化,成员单位,和实体导航性能的支持。


    The specified type member 'DeleteFlag' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.

    出现这个问题的原因是因为在linq中两个连接表创建的实体类需要吧其中的映射字段每一个都查出来,不然就会报这个错误,错误的写法如下

                    var querySql = from t in _observationResultRepository.Table
                                   join r in _observationRequestRepository.Table
                                   on t.ObservationUID equals r.ObservationUID
                                   select new RelatedLabResultInfo 
                                   {
                                       ValueText=t.ValueText,
                                       ResultDate=r.ResultDate
                                   };
      if (query.ClinicInfoType != null)
                    {
                        querySql = querySql.Where(u => u.ClinicInfoType == query.ClinicInfoType.Value.ToString());
                    }

    这其中,tostringEF 不支持,需要写个中间变量赋值然后再放在EF中,

    正确的写法:

                    var querySql = from t in _observationResultRepository.Table
                                   join r in _observationRequestRepository.Table
                                   on t.ObservationUID equals r.ObservationUID
                                   select new RelatedLabResultInfo 
                                   {
                                       ValueText=t.ValueText,
                                       ResultDate=r.ResultDate,
                                       ClinicInfoType=r.ClinicInfoType
                                   };
    
      if (query.ClinicInfoType != null) 
                    {
                        ClinicInfoType = query.ClinicInfoType.Value.ToString();
                    }
    
    if (query.ClinicInfoType != null)
                    {
                        querySql = querySql.Where(u => u.ClinicInfoType == ClinicInfoType);
                    }
  • 相关阅读:
    python os模块
    python time、datetime模块
    python 导入模块、包
    python json、pickle
    python 装饰器
    python 生成器、迭代器
    python 内置函数
    python 函数的参数
    python 编码解码
    python 文件读写、shutil模块
  • 原文地址:https://www.cnblogs.com/llcdbk/p/6979623.html
Copyright © 2020-2023  润新知