2 回答
TA贡献1909条经验 获得超7个赞
LINQ 的.Where
回报IEnumerable<T>
,你的模型需要一个List<T>
,你可以改变你的模型,IEnumerable<T>
或者你可以改变这行代码:
DependentsDocuments = employee.DependentsDocuments .Where(x => x.dependentId == dependentId)
对此:
DependentsDocuments = employee.DependentsDocuments .Where(x => x.dependentId == dependentId) .ToList()
TA贡献1876条经验 获得超7个赞
将您的代码更改为此代码可能有效:
public async Task<List<Documents>> GetDocument(string ownerId, string dependentId)
{
var query = (from employee in _employee.AsQueryable()
where employee.ownerId == ownerId
select new Employee()
{
DependentsDocuments = employee.DependentsDocuments.Where(x => x.dependentId == dependentId).ToList()
}).ToList();
return query.ToList();
}
- 2 回答
- 0 关注
- 63 浏览
添加回答
举报