For some reason only the first item of each array is being returned as JSON, any clues why?
Here is what I see during debugging, as you can tell, I have two items in 'Category' and two items in 'Tasks':
Postman JSON result (it should return all items, shouldn't it?):

For reference, here is my 'Category.cs':
public class Category
{
public int CategoryId { get; set; }
public string Name { get; set; }
public DateTime Timestamp { get; set; }
public string Username { get; set; }
public ApplicationUser ApplicationUser { get; set; }
public virtual ICollection<Task> Tasks { get; set; }
}
My 'Task.cs':
public class Task
{
public int TaskId { get; set; }
public string Name { get; set; }
public DateTime Timestamp { get; set; }
public virtual Category Category { get; set; }
}
and my Api:
[HttpGet]
public JsonResult Get()
{
var result = _repo.GetAllForUser("[email protected]");
return Json(result);
}
And repository:
public IEnumerable<Category> GetAllForUser(string name)
{
return _ctx.Categories
.Where(c => c.ApplicationUser.UserName == name)
.Include(c => c.Tasks)
.ToList();
}
Here is what I insert into database, and what I should retrieve from the Api:
categories.Add(new Category
{
Name = "cat 1",
Tasks = new List<Task>
{
new Task { Name="task 1" },
new Task { Name="task 2" }
}
});
categories.Add(new Category
{
Name = "cat 2",
Tasks = new List<Task>
{
new Task { Name="task 3" },
new Task { Name="task 4" }
}
});

Taskmodel looks like?dotnet runand enable console logging)