From e9ce346e6350e07b5ad5fdccb84cf7c5973d5b85 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 7 Jun 2022 15:59:00 +0800 Subject: [PATCH] Navigate query support skip take --- Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs | 4 ++++ .../Abstract/QueryableProvider/NavigatManager.cs | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs index b1d2fe38c..3ff650983 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs @@ -108,6 +108,10 @@ namespace OrmTest var list3_1 = db.Queryable() .Includes(x => x.Books.MappingField(z=>z.Names,()=>x.Name).ToList()) + .ToList(); + + var list3_11 = db.Queryable() + .Includes(x => x.Books.Skip(1).Take(2).ToList()) .ToList(); //先用Mapper导航映射查出第二层 diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs index 7808f8029..3a90e47d6 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs @@ -336,21 +336,31 @@ namespace SqlSugar }).GroupBy(it => it.l).ToList(); foreach (var item in groupQuery) { - + var itemSelectList=item.Select(it => it.n); + if (sqlObj.Skip != null) + { + itemSelectList = itemSelectList + .Skip(sqlObj.Skip.Value); + } + if (sqlObj.Take != null) + { + itemSelectList = itemSelectList + .Take(sqlObj.Take.Value); + } if (sqlObj.MappingExpressions.HasValue()) { MappingFieldsHelper helper = new MappingFieldsHelper(); helper.NavEntity = navEntityInfo; helper.Context = this.Context; helper.RootEntity = this.Context.EntityMaintenance.GetEntityInfo(); - helper.SetChildList(navObjectNameColumnInfo, item.Key, item.Select(it => it.n).ToList(), sqlObj.MappingExpressions); + helper.SetChildList(navObjectNameColumnInfo, item.Key, itemSelectList.ToList(), sqlObj.MappingExpressions); } else { var instance = Activator.CreateInstance(navObjectNamePropety.PropertyType, true); var ilist = instance as IList; - foreach (var value in item.Select(it => it.n).ToList()) + foreach (var value in itemSelectList.ToList()) { ilist.Add(value); }