Update mapper

This commit is contained in:
SUNKAIXUAN 2021-03-04 19:36:16 +08:00
parent 6b4e0b4f20
commit d3d5a1fdd4
6 changed files with 44 additions and 3 deletions

View File

@ -44,6 +44,8 @@ namespace OrmTest
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
public string Name { get; set; }
[SugarColumn(IsIgnore = true)]
public List<B> BList { get; set; }
}
public class B
{

View File

@ -93,6 +93,15 @@ namespace OrmTest
var qu4 = Db.Queryable<Order>().OrderBy(it=>it.Id+it.Id).ToList();
var list11 = Db.Queryable<A>()
.ToList();
//var list8 = Db.Queryable<A>()
//.Mapper<ABMapping>(it=>ManyToMany.Config(it.A,it.AId,it.B,it.BId))
//.ToList();
}
}
}

View File

@ -22,7 +22,7 @@ namespace SqlSugar
public ISqlBuilder SqlBuilder { get; set; }
public MappingTableList OldMappingTableList { get; set; }
public MappingTableList QueryableMappingTableList { get; set; }
public Action<T> MapperAction { get; set; }
public List<Action<T>> MapperAction { get; set; }
public Action<T, MapperCache<T>> MapperActionWithCache { get; set; }
public List<Action<List<T>>> Mappers { get; set; }
public bool IsCache { get; set; }
@ -105,7 +105,12 @@ namespace SqlSugar
public virtual ISugarQueryable<T> Mapper(Action<T> mapperAction)
{
this.MapperAction = mapperAction;
this.MapperAction=UtilMethods.IsNullReturnNew(this.MapperAction);
this.MapperAction.Add(mapperAction);
return this;
}
public ISugarQueryable<T> Mapper<MappingType>(Expression<Func<MappingType, ManyToMany>> expression)
{
return this;
}
public virtual ISugarQueryable<T> Mapper(Action<T, MapperCache<T>> mapperAction)
@ -1608,7 +1613,10 @@ namespace SqlSugar
{
if (typeof(TResult) == typeof(T))
{
this.MapperAction((T)(item as object));
foreach (var mapper in this.MapperAction)
{
mapper((T)(item as object));
}
}
else
{

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class ManyToMany
{
public static ManyToMany Config<AClass,AField,BClass,BField>(AClass aClass,AField aField,BClass bClass,BField bField)
where AClass:class
where AField : struct
where BClass:class
where BField:struct
{
return null;
}
}
}

View File

@ -20,6 +20,7 @@ namespace SqlSugar
ISugarQueryable<T> With(string withString);
ISugarQueryable<T> Filter(string FilterName, bool isDisabledGobalFilter = false);
ISugarQueryable<T> Mapper(Action<T> mapperAction);
ISugarQueryable<T> Mapper<MappingType>(Expression<Func<MappingType, ManyToMany>> expression);
ISugarQueryable<T> Mapper(Action<T, MapperCache<T>> mapperAction);
ISugarQueryable<T> Mapper<TObject>(Expression<Func<T, TObject>> mapperObject, Expression<Func<T, object>> mainField, Expression<Func<T, object>> childField);
ISugarQueryable<T> Mapper<TObject>(Expression<Func<T, List<TObject>>> mapperObject, Expression<Func<T, object>> mainField, Expression<Func<T, object>> childField);

View File

@ -89,6 +89,7 @@
<Compile Include="Abstract\InsertableProvider\InsertableProvider.cs" />
<Compile Include="Abstract\DeleteProvider\DeleteableProvider.cs" />
<Compile Include="Abstract\SaveableProvider\Storageable.cs" />
<Compile Include="Entities\ManyToManyConfig.cs" />
<Compile Include="Entities\StackTraceInfo.cs" />
<Compile Include="Entities\SubInsertTree.cs" />
<Compile Include="ExpressionsToSql\Common\MapperExpression.cs" />