如何解决此转化问题?查询生成正确的结果,但不能返回List
public class Category
{
public int CategoryId { get; set; }
public string Name { get; set; }
public DateTime Timestamp { get; set; }
public ICollection<Task> Tasks { get; set; }
}
public class Task
{
public int TaskId { get; set; }
public string Name { get; set; }
public DateTime Timestamp { get; set; }
}
public class ApplicationUser : IdentityUser
{
public ICollection<Category> Categories { get; set; }
}
导致问题的代码:
public List<Category> GetAllForUser(string name)
{
return _ctx.Users
.Include(x => x.Categories)
.ThenInclude(x => x.Tasks)
.Where(x => x.UserName == "val")
.Select(x => x.Categories).ToList();