这是我的.net核心2 web api方法,
[HttpGet]
public List<Clients> GetClientsWithUsers() // public IEnumerable<Clients> GetClientsWithUsers()
{
var clientsWithUsers = _context.Clients.Include(c => c.Users).ToList(); //.ToArray()
return clientsWithUsers;
}
public partial class Clients
{
public Clients()
{
Users = new HashSet<Users>();
}
public int ClientId { get; set; }
public string Name { get; set; }
public int? MaxUsers { get; set; }
public ICollection<Users> Users { get; set; }
}
public partial class Users
{
public int Id { get; set; }
public string Name { get; set; }
public int ClientId { get; set; }
public DateTime LastAccessed { get; set; }
public Clients Client { get; set; }
}
我在浏览器中获得的结果将被截断:
[{ “的clientId”:1, “名称”: “TestClientName”, “MAXUSERS”:12, “用户”:[{ “ID”:3 “名称”:“一些 名称”, “的clientId”:1, “上次访问”: “2015-11-27T00:00:00”
我不知道为什么我的结构破碎了。