use*_*865 1 c# linq entity-framework .net-core webapi
var list1 = _context.Employees.Where(x=> x.EmployeeId.Equals(empId)
&& **x.deptIds.Split(",")**.ToList().Any(p => (p!=(deptId.ToString()))));
Run Code Online (Sandbox Code Playgroud)
其中,x.deptIds 是以逗号分隔的字符串形式存储的部门 ID。出现错误“表达式树可能不包含使用可选参数的调用或调用”。怎么解决呢?
Hir*_*Yui 16
只需指定一个可选参数即可。string.Split(",")变成string.Split(",", System.StringSplitOptions.None)
向 string.Split 提供可选参数解决了我的错误