mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 16:18:47 +08:00
Update mapper
This commit is contained in:
parent
6b4e0b4f20
commit
d3d5a1fdd4
@ -44,6 +44,8 @@ namespace OrmTest
|
|||||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
[SugarColumn(IsIgnore = true)]
|
||||||
|
public List<B> BList { get; set; }
|
||||||
}
|
}
|
||||||
public class B
|
public class B
|
||||||
{
|
{
|
||||||
|
@ -93,6 +93,15 @@ namespace OrmTest
|
|||||||
|
|
||||||
|
|
||||||
var qu4 = Db.Queryable<Order>().OrderBy(it=>it.Id+it.Id).ToList();
|
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();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace SqlSugar
|
|||||||
public ISqlBuilder SqlBuilder { get; set; }
|
public ISqlBuilder SqlBuilder { get; set; }
|
||||||
public MappingTableList OldMappingTableList { get; set; }
|
public MappingTableList OldMappingTableList { get; set; }
|
||||||
public MappingTableList QueryableMappingTableList { 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 Action<T, MapperCache<T>> MapperActionWithCache { get; set; }
|
||||||
public List<Action<List<T>>> Mappers { get; set; }
|
public List<Action<List<T>>> Mappers { get; set; }
|
||||||
public bool IsCache { get; set; }
|
public bool IsCache { get; set; }
|
||||||
@ -105,7 +105,12 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public virtual ISugarQueryable<T> Mapper(Action<T> mapperAction)
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
public virtual ISugarQueryable<T> Mapper(Action<T, MapperCache<T>> mapperAction)
|
public virtual ISugarQueryable<T> Mapper(Action<T, MapperCache<T>> mapperAction)
|
||||||
@ -1608,7 +1613,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
if (typeof(TResult) == typeof(T))
|
if (typeof(TResult) == typeof(T))
|
||||||
{
|
{
|
||||||
this.MapperAction((T)(item as object));
|
foreach (var mapper in this.MapperAction)
|
||||||
|
{
|
||||||
|
mapper((T)(item as object));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
20
Src/Asp.Net/SqlSugar/Entities/ManyToManyConfig.cs
Normal file
20
Src/Asp.Net/SqlSugar/Entities/ManyToManyConfig.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,7 @@ namespace SqlSugar
|
|||||||
ISugarQueryable<T> With(string withString);
|
ISugarQueryable<T> With(string withString);
|
||||||
ISugarQueryable<T> Filter(string FilterName, bool isDisabledGobalFilter = false);
|
ISugarQueryable<T> Filter(string FilterName, bool isDisabledGobalFilter = false);
|
||||||
ISugarQueryable<T> Mapper(Action<T> mapperAction);
|
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(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, 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);
|
ISugarQueryable<T> Mapper<TObject>(Expression<Func<T, List<TObject>>> mapperObject, Expression<Func<T, object>> mainField, Expression<Func<T, object>> childField);
|
||||||
|
@ -89,6 +89,7 @@
|
|||||||
<Compile Include="Abstract\InsertableProvider\InsertableProvider.cs" />
|
<Compile Include="Abstract\InsertableProvider\InsertableProvider.cs" />
|
||||||
<Compile Include="Abstract\DeleteProvider\DeleteableProvider.cs" />
|
<Compile Include="Abstract\DeleteProvider\DeleteableProvider.cs" />
|
||||||
<Compile Include="Abstract\SaveableProvider\Storageable.cs" />
|
<Compile Include="Abstract\SaveableProvider\Storageable.cs" />
|
||||||
|
<Compile Include="Entities\ManyToManyConfig.cs" />
|
||||||
<Compile Include="Entities\StackTraceInfo.cs" />
|
<Compile Include="Entities\StackTraceInfo.cs" />
|
||||||
<Compile Include="Entities\SubInsertTree.cs" />
|
<Compile Include="Entities\SubInsertTree.cs" />
|
||||||
<Compile Include="ExpressionsToSql\Common\MapperExpression.cs" />
|
<Compile Include="ExpressionsToSql\Common\MapperExpression.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user