Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Can';无法从模型中获取ASP.Net中的相关数据_C#_Asp.net_Entity Framework_Linq To Entities - Fatal编程技术网

C# Can';无法从模型中获取ASP.Net中的相关数据

C# Can';无法从模型中获取ASP.Net中的相关数据,c#,asp.net,entity-framework,linq-to-entities,C#,Asp.net,Entity Framework,Linq To Entities,我刚开始学习ASP.Net内核,和我的关系有一些问题 在我的啤酒模型中,我具有以下导航属性: /* Navigation Properties */ public int BreweryID { get; set; } public Brewery Brewery { get; set; } /* Navigation Properties */ public ICollection<Beer> Beers { get; set; } 在我的Brewery模型中,我具有以下导航属

我刚开始学习ASP.Net内核,和我的关系有一些问题

在我的啤酒模型中,我具有以下导航属性:

/* Navigation Properties */
public int BreweryID { get; set; }
public Brewery Brewery { get; set; }
/* Navigation Properties */
public ICollection<Beer> Beers { get; set; }
在我的Brewery模型中,我具有以下导航属性:

/* Navigation Properties */
public int BreweryID { get; set; }
public Brewery Brewery { get; set; }
/* Navigation Properties */
public ICollection<Beer> Beers { get; set; }
//酿酒厂

 {
    "id": 7,
    "name": "Moortgat",
    "address": "test",
    "founder": "test",
    "foundationYear": "2008-01-10T00:00:00.123",
    "description": "test",
    "website": "test",
    "beers": null,
    "imageID": 3,
    "image": null
}

有什么建议吗

查询中不包括啤酒的相关实体。请包括同样的内容
_context.Breweries.Include(brewery=>brewery.Beers)

查询中不包括啤酒的相关实体。请包括同样的内容 _context.Breweries.Include(brewery=>brewery.Beers)

试试这个

return await _context.Breweries
    .Include(x => x.Beers)
    .ToListAsync();
试试这个

return await _context.Breweries
    .Include(x => x.Beers)
    .ToListAsync();

此线程中指定了您现在的确切问题


此线程中指定了您现在的确切问题


谢谢你的回答。我以前试过这个,但在《邮递员》中得到了一个错误响应。错误为:System.Text.Json.JsonException:检测到不支持的可能的对象循环。这可能是由于一个循环,或者如果对象深度大于允许的最大深度32。假设您在Core 3.0上,这些文章可能会有所帮助:谢谢您的回答。我以前试过这个,但在《邮递员》中得到了一个错误响应。错误为:System.Text.Json.JsonException:检测到不支持的可能的对象循环。这可能是由于一个循环,或者如果对象深度大于允许的最大深度32。假设您使用的是Core 3.0,这些文章可能会有所帮助:谢谢@Dee P的回答。当我这样做时,我得到一个异常响应。System.Text.Json.JsonException:检测到不支持的可能的对象循环。这可能是由于循环或对象深度大于允许的最大深度32。感谢@Dee P的回答。当我这样做时,我得到一个异常响应。System.Text.Json.JsonException:检测到不支持的可能的对象循环。这可能是由于循环造成的,或者如果对象深度大于允许的最大深度32。