2 回答

TA貢獻1909條經(jīng)驗 獲得超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條經(jīng)驗 獲得超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 關注
- 87 瀏覽
添加回答
舉報