Navigate query support skip take

This commit is contained in:
sunkaixuan 2022-06-07 15:59:00 +08:00
parent 658e15ec45
commit e9ce346e63
2 changed files with 17 additions and 3 deletions

View File

@ -108,6 +108,10 @@ namespace OrmTest
var list3_1 = db.Queryable<StudentA>() var list3_1 = db.Queryable<StudentA>()
.Includes(x => x.Books.MappingField(z=>z.Names,()=>x.Name).ToList()) .Includes(x => x.Books.MappingField(z=>z.Names,()=>x.Name).ToList())
.ToList();
var list3_11 = db.Queryable<StudentA>()
.Includes(x => x.Books.Skip(1).Take(2).ToList())
.ToList(); .ToList();
//先用Mapper导航映射查出第二层 //先用Mapper导航映射查出第二层

View File

@ -336,21 +336,31 @@ namespace SqlSugar
}).GroupBy(it => it.l).ToList(); }).GroupBy(it => it.l).ToList();
foreach (var item in groupQuery) 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()) if (sqlObj.MappingExpressions.HasValue())
{ {
MappingFieldsHelper<T> helper = new MappingFieldsHelper<T>(); MappingFieldsHelper<T> helper = new MappingFieldsHelper<T>();
helper.NavEntity = navEntityInfo; helper.NavEntity = navEntityInfo;
helper.Context = this.Context; helper.Context = this.Context;
helper.RootEntity = this.Context.EntityMaintenance.GetEntityInfo<T>(); helper.RootEntity = this.Context.EntityMaintenance.GetEntityInfo<T>();
helper.SetChildList(navObjectNameColumnInfo, item.Key, item.Select(it => it.n).ToList(), sqlObj.MappingExpressions); helper.SetChildList(navObjectNameColumnInfo, item.Key, itemSelectList.ToList(), sqlObj.MappingExpressions);
} }
else else
{ {
var instance = Activator.CreateInstance(navObjectNamePropety.PropertyType, true); var instance = Activator.CreateInstance(navObjectNamePropety.PropertyType, true);
var ilist = instance as IList; var ilist = instance as IList;
foreach (var value in item.Select(it => it.n).ToList()) foreach (var value in itemSelectList.ToList())
{ {
ilist.Add(value); ilist.Add(value);
} }