Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.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
Asp.net mvc 当延迟加载和代理为false时,如何在注释表中递归加载n个子项?_Asp.net Mvc_Performance_Entity Framework_Linq - Fatal编程技术网

Asp.net mvc 当延迟加载和代理为false时,如何在注释表中递归加载n个子项?

Asp.net mvc 当延迟加载和代理为false时,如何在注释表中递归加载n个子项?,asp.net-mvc,performance,entity-framework,linq,Asp.net Mvc,Performance,Entity Framework,Linq,我想通过Linq查询获得具有导航属性的所有注释。我在实体中禁用了延迟加载和代理 public partial class dbCommentEntities : DbContext { public dbCommentEntities() : base("name=dbCommentEntities") { this.Configuration.LazyLoadingEnabled = false; this.Configurati

我想通过Linq查询获得具有导航属性的所有注释。我在实体中禁用了延迟加载和代理

public partial class dbCommentEntities : DbContext
{
    public dbCommentEntities()
        : base("name=dbCommentEntities")
    {
        this.Configuration.LazyLoadingEnabled = false;
        this.Configuration.ProxyCreationEnabled = false;

    }
}
我从数据库加载的查询代码是

 var queryTest = (from c in db.Comments
                         where c.ParentId == null
                         orderby c.CommentId descending
                         select new minicomment { 
                            Title = c.Title,
                            CommentId = c.CommentId, 
                            Comments1 = c.Comments1}).Skip(skip).Take(take);      
现在,如果在我的
dbcontext
中启用延迟加载和代理,对我来说就可以了。这意味着获得所有级别的导航

但这是禁用或启用等于假,它只为我加载一个级别

当lazy和proxy为false时,如何获得所有级别的导航


谢谢。

您必须使用
快速加载

好文章

什么是快速加载?

使用即时加载时,相关实体将与 您的目标实体集。您可以在查询中使用Include语句 指明要引入哪些相关实体

例如:

 return (from owner in Catalog.Owners
                        where owner.Key == ownerKey
                         select owner)
                        .Include(o => o.Credits)
                        .Include(o => o.Provider)

您得到的错误是什么?我只给出了错误的数据,没有错误。include方法加载所有记录。这对表演没有好处。我需要一个在表中搜索的算法。例如,我想要5条带有nmulti-level导航的注释。我使用页面列表。它具有用于选择的skip和take以及用于加载的limite记录。