mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-16 04:59:34 +08:00
Update .net core project
This commit is contained in:
parent
8a528196ff
commit
f7de1cacd4
@ -74,11 +74,11 @@ namespace SqlSugar
|
||||
|
||||
private bool IsDeleteA()
|
||||
{
|
||||
return deleteNavOptions != null && deleteNavOptions.ManyToMayIsDeleteA;
|
||||
return deleteNavOptions != null && deleteNavOptions.ManyToManyIsDeleteA;
|
||||
}
|
||||
private bool IsDeleteB()
|
||||
{
|
||||
return deleteNavOptions != null && deleteNavOptions.ManyToMayIsDeleteB;
|
||||
return deleteNavOptions != null && deleteNavOptions.ManyToManyIsDeleteB;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,10 @@ namespace SqlSugar
|
||||
{
|
||||
return AsNav().ThenInclude(expression);
|
||||
}
|
||||
public DeleteNavTask<Root, TChild> Include<TChild>(Expression<Func<Root, List<TChild>>> expression,DeleteNavOptions options) where TChild : class, new()
|
||||
{
|
||||
return AsNav().ThenInclude(expression, options);
|
||||
}
|
||||
public bool ExecuteCommand()
|
||||
{
|
||||
PreFunc();
|
||||
|
@ -10,7 +10,6 @@ namespace SqlSugar
|
||||
{
|
||||
private void UpdateManyToMany<TChild>(string name, EntityColumnInfo nav) where TChild : class, new()
|
||||
{
|
||||
;
|
||||
var parentEntity = _ParentEntity;
|
||||
var parentList = _ParentList;
|
||||
var parentPkColumn = parentEntity.Columns.FirstOrDefault(it => it.IsPrimarykey == true);
|
||||
@ -33,7 +32,14 @@ namespace SqlSugar
|
||||
{
|
||||
var items = parentNavigateProperty.PropertyInfo.GetValue(item);
|
||||
var children = ((List<TChild>)items);
|
||||
if (this._Options != null && this._Options.ManyToManyIsUpdateB)
|
||||
{
|
||||
InsertDatas(children, thisPkColumn);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ParentList = children.Cast<object>().ToList();
|
||||
}
|
||||
var parentId = parentPkColumn.PropertyInfo.GetValue(item);
|
||||
foreach (var child in children)
|
||||
{
|
||||
@ -51,6 +57,7 @@ namespace SqlSugar
|
||||
var ids = mappgingTables.Select(x => x[mappingA.DbColumnName]).ToList();
|
||||
this._Context.Deleteable<object>().AS(mappingEntity.DbTableName).In(mappingA.DbColumnName, ids).ExecuteCommand();
|
||||
this._Context.Insertable(mappgingTables).AS(mappingEntity.DbTableName).ExecuteCommand();
|
||||
_ParentEntity = thisEntity;
|
||||
}
|
||||
|
||||
private void SetMappingTableDefaultValue(EntityColumnInfo mappingPk, Dictionary<string, object> keyValuePairs)
|
||||
|
@ -17,7 +17,7 @@ namespace SqlSugar
|
||||
public EntityColumnInfo _ParentPkColumn { get; set; }
|
||||
public SqlSugarProvider _Context { get; set; }
|
||||
|
||||
|
||||
public UpdateNavOptions _Options { get; set; }
|
||||
public UpdateNavProvider<Root, Root> AsNav()
|
||||
{
|
||||
return new UpdateNavProvider<Root, Root>
|
||||
@ -30,6 +30,28 @@ namespace SqlSugar
|
||||
};
|
||||
}
|
||||
public UpdateNavProvider<Root, TChild> ThenInclude<TChild>(Expression<Func<T, TChild>> expression) where TChild : class, new()
|
||||
{
|
||||
return _ThenInclude(expression);
|
||||
}
|
||||
|
||||
public UpdateNavProvider<Root, TChild> ThenInclude<TChild>(Expression<Func<T, List<TChild>>> expression) where TChild : class, new()
|
||||
{
|
||||
return _ThenInclude(expression);
|
||||
}
|
||||
|
||||
public UpdateNavProvider<Root, TChild> ThenInclude<TChild>(Expression<Func<T, TChild>> expression,UpdateNavOptions options) where TChild : class, new()
|
||||
{
|
||||
_Options= options;
|
||||
return _ThenInclude(expression);
|
||||
}
|
||||
|
||||
public UpdateNavProvider<Root, TChild> ThenInclude<TChild>(Expression<Func<T, List<TChild>>> expression, UpdateNavOptions options) where TChild : class, new()
|
||||
{
|
||||
_Options = options;
|
||||
return _ThenInclude(expression);
|
||||
}
|
||||
|
||||
private UpdateNavProvider<Root, TChild> _ThenInclude<TChild>(Expression<Func<T, TChild>> expression) where TChild : class, new()
|
||||
{
|
||||
InitParentList();
|
||||
var name = ExpressionTool.GetMemberName(expression);
|
||||
@ -52,7 +74,8 @@ namespace SqlSugar
|
||||
}
|
||||
return GetResult<TChild>();
|
||||
}
|
||||
public UpdateNavProvider<Root, TChild> ThenInclude<TChild>(Expression<Func<T, List<TChild>>> expression) where TChild : class, new()
|
||||
|
||||
private UpdateNavProvider<Root, TChild> _ThenInclude<TChild>(Expression<Func<T, List<TChild>>> expression) where TChild : class, new()
|
||||
{
|
||||
InitParentList();
|
||||
var name = ExpressionTool.GetMemberName(expression);
|
||||
|
@ -17,8 +17,11 @@ namespace SqlSugar
|
||||
private void InitParentList()
|
||||
{
|
||||
if (_RootList == null)
|
||||
{
|
||||
if (_Options != null && _Options.ManyToManyIsUpdateA)
|
||||
{
|
||||
this._Context.Updateable(_Roots).ExecuteCommand();
|
||||
}
|
||||
_RootList = _ParentList = _Roots.Cast<object>().ToList();
|
||||
_ParentEntity = this._Context.EntityMaintenance.GetEntityInfo<Root>();
|
||||
}
|
||||
|
@ -31,11 +31,33 @@ namespace SqlSugar
|
||||
result.Context = this.Context;
|
||||
return result;
|
||||
}
|
||||
|
||||
public UpdateNavTask<Root, TChild> Include<TChild>(Expression<Func<Root, TChild>> expression,UpdateNavOptions options) where TChild : class, new()
|
||||
{
|
||||
this.Context = UpdateNavProvider._Context;
|
||||
UpdateNavTask<Root, TChild> result = new UpdateNavTask<Root, TChild>();
|
||||
Func<UpdateNavProvider<Root, TChild>> func = () => UpdateNavProvider.ThenInclude(expression,options);
|
||||
result.PreFunc = func;
|
||||
result.Context = this.Context;
|
||||
return result;
|
||||
}
|
||||
public UpdateNavTask<Root, TChild> Include<TChild>(Expression<Func<Root, List<TChild>>> expression, UpdateNavOptions options) where TChild : class, new()
|
||||
{
|
||||
this.Context = UpdateNavProvider._Context;
|
||||
UpdateNavTask<Root, TChild> result = new UpdateNavTask<Root, TChild>();
|
||||
Func<UpdateNavProvider<Root, TChild>> func = () => UpdateNavProvider.ThenInclude(expression,options);
|
||||
result.PreFunc = func;
|
||||
result.Context = this.Context;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public class UpdateNavTask<Root, T> where T : class, new() where Root : class, new()
|
||||
{
|
||||
public SqlSugarProvider Context { get; set; }
|
||||
public Func<UpdateNavProvider<Root, T>> PreFunc { get; set; }
|
||||
|
||||
|
||||
#region +1
|
||||
public UpdateNavTask<Root, TChild> ThenInclude<TChild>(Expression<Func<T, TChild>> expression) where TChild : class, new()
|
||||
{
|
||||
UpdateNavTask<Root, TChild> result = new UpdateNavTask<Root, TChild>();
|
||||
@ -60,6 +82,38 @@ namespace SqlSugar
|
||||
{
|
||||
return AsNav().ThenInclude(expression);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region +2
|
||||
public UpdateNavTask<Root, TChild> ThenInclude<TChild>(Expression<Func<T, TChild>> expression, UpdateNavOptions options) where TChild : class, new()
|
||||
{
|
||||
UpdateNavTask<Root, TChild> result = new UpdateNavTask<Root, TChild>();
|
||||
Func<UpdateNavProvider<Root, TChild>> func = () => PreFunc().ThenInclude(expression, options);
|
||||
result.PreFunc = func;
|
||||
result.Context = this.Context;
|
||||
return result;
|
||||
}
|
||||
public UpdateNavTask<Root, TChild> ThenInclude<TChild>(Expression<Func<T, List<TChild>>> expression, UpdateNavOptions options) where TChild : class, new()
|
||||
{
|
||||
UpdateNavTask<Root, TChild> result = new UpdateNavTask<Root, TChild>();
|
||||
Func<UpdateNavProvider<Root, TChild>> func = () => PreFunc().ThenInclude(expression, options);
|
||||
result.PreFunc = func;
|
||||
result.Context = this.Context;
|
||||
return result;
|
||||
}
|
||||
public UpdateNavTask<Root, TChild> Include<TChild>(Expression<Func<Root, TChild>> expression, UpdateNavOptions options) where TChild : class, new()
|
||||
{
|
||||
return AsNav().ThenInclude(expression, options);
|
||||
}
|
||||
public UpdateNavTask<Root, TChild> Include<TChild>(Expression<Func<Root, List<TChild>>> expression, UpdateNavOptions options) where TChild : class, new()
|
||||
{
|
||||
return AsNav().ThenInclude(expression, options);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
public bool ExecuteCommand()
|
||||
{
|
||||
var hasTran = this.Context.Ado.Transaction != null;
|
||||
|
@ -8,7 +8,12 @@ namespace SqlSugar
|
||||
{
|
||||
public class DeleteNavOptions
|
||||
{
|
||||
public bool ManyToMayIsDeleteA { get; set; }
|
||||
public bool ManyToMayIsDeleteB { get; set; }
|
||||
public bool ManyToManyIsDeleteA { get; set; }
|
||||
public bool ManyToManyIsDeleteB { get; set; }
|
||||
}
|
||||
public class UpdateNavOptions
|
||||
{
|
||||
public bool ManyToManyIsUpdateA { get; set; }
|
||||
public bool ManyToManyIsUpdateB { get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user