Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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
.net core EF Core使用“创建对象”;“无限”;深度_.net Core_Ef Core 2.0 - Fatal编程技术网

.net core EF Core使用“创建对象”;“无限”;深度

.net core EF Core使用“创建对象”;“无限”;深度,.net-core,ef-core-2.0,.net Core,Ef Core 2.0,我的数据库中有一个M到N的关系。我从MySql页面获取了示例数据库“sakila”。我已按如下方式设置了模型对象 胶片表 public partial class Film { public Film() { FilmActor = new HashSet<FilmActor>(); FilmCategory = new HashSet<FilmCategory>();

我的数据库中有一个M到N的关系。我从MySql页面获取了示例数据库“sakila”。我已按如下方式设置了模型对象

胶片表

public partial class Film
    {
        public Film()
        {
            FilmActor = new HashSet<FilmActor>();
            FilmCategory = new HashSet<FilmCategory>();
            Inventory = new HashSet<Inventory>();
        }

        //Some Properties


        public ICollection<Inventory> Inventory { get; set; }
    }
public partial class Store
    {
        public Store()
        {
            Customer = new HashSet<Customer>();
            Inventory = new HashSet<Inventory>();
            Staff = new HashSet<Staff>();
        }

        //More Properties
        public ICollection<Inventory> Inventory { get; set; }

    }
公共部分类电影
{
公共电影()
{
FilmActor=newhashset();
FilmCategory=newhashset();
Inventory=新的HashSet();
}
//一些性质
公共ICollection清单{get;set;}
}
链接表库存

public partial class Inventory
    {
        public Inventory()
        {
            Rental = new HashSet<Rental>();
        }

        public int InventoryId { get; set; }
        public short FilmId { get; set; }
        public byte StoreId { get; set; }
        public DateTimeOffset LastUpdate { get; set; }

        public Film Film { get; set; }
        public Store Store { get; set; }
        public ICollection<Rental> Rental { get; set; }
    }
公共部分类目录
{
公共库存()
{
Rental=新HashSet();
}
public int InventoryId{get;set;}
公共短片ID{get;set;}
公共字节存储ID{get;set;}
公共DateTimeOffset LastUpdate{get;set;}
公共电影{get;set;}
公共存储{get;set;}
公共ICollection出租{get;set;}
}
存储表

public partial class Film
    {
        public Film()
        {
            FilmActor = new HashSet<FilmActor>();
            FilmCategory = new HashSet<FilmCategory>();
            Inventory = new HashSet<Inventory>();
        }

        //Some Properties


        public ICollection<Inventory> Inventory { get; set; }
    }
public partial class Store
    {
        public Store()
        {
            Customer = new HashSet<Customer>();
            Inventory = new HashSet<Inventory>();
            Staff = new HashSet<Staff>();
        }

        //More Properties
        public ICollection<Inventory> Inventory { get; set; }

    }
公共部分类存储
{
公共商店()
{
Customer=newhashset();
Inventory=新的HashSet();
Staff=新HashSet();
}
//更多属性
公共ICollection清单{get;set;}
}
当我通过存储库检索数据时,我会得到一个商店对象列表,该列表包含一个库存列表,该列表包含一个电影列表,该列表包含一个商店列表。。。 换句话说:商店[2]->库存[2270]->电影->商店[2]->库存。。。无限的


那么,当我的模型到达胶片对象时,我该如何停止

实体框架在查询数据库对象时默认跟踪它们。如果通过延迟加载或快速加载获取查询中的子对象或父对象,它们将“存储”在(本地)上下文中

这意味着,无论何时进入调试模式并点击断点,您都可以无限步地遍历对象树。
在运行时,这对性能没有实际影响。

我将问另一个问题,现在我知道这与EF Core无关,但似乎是Postman的问题。谢谢你的帮助。