Cannot compare elements of type 'System.Collections.Generic.ICollection`1 Only primitive types, enumeration types and entity types are supported

前端 未结 6 1760
别跟我提以往
别跟我提以往 2020-12-15 16:29

I have written this code

IQueryable sites = context.MainTable.Include(\"RelatedTable\");

if (!string.IsNullOrEmpty(param1)) {
    sites = sites.         


        
6条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 16:50

    It work me , I just remove the null check;

    correct: result=

    db.EmpTable.FirstOrDefault().ProjectsAssign.Name,

    InCorrect : result=

    db.EmpTable!=null && db.EmpTable.FirstOrDefault().ProjectsAssign!=null ? 
          db.EmpTable.FirstOrDefault().ProjectsAssign.Name : null,

提交回复
热议问题