mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Synchronization code
This commit is contained in:
parent
8b39edefb5
commit
15b4728c06
@ -46,9 +46,34 @@ namespace SqlSugar
|
||||
if (NotAny(name))
|
||||
{
|
||||
DeleteMany(thisEntity, ids, thisFkColumn.DbColumnName);
|
||||
this._Context.Deleteable<object>()
|
||||
.AS(thisEntity.DbTableName)
|
||||
.In(thisFkColumn.DbColumnName, ids.Distinct().ToList()).ExecuteCommand();
|
||||
if (this._Options?.OneToManyEnableLogicDelete == true)
|
||||
{
|
||||
var locgicColumn = thisEntity.Columns.FirstOrDefault(it => it.PropertyName.EqualCase("IsDeleted") || it.PropertyName.EqualCase("IsDelete"));
|
||||
Check.ExceptionEasy(
|
||||
locgicColumn==null,
|
||||
thisEntity.EntityName + "Logical deletion requires the entity to have the IsDeleted property",
|
||||
thisEntity.EntityName+"假删除需要实体有IsDeleted属性");
|
||||
List<IConditionalModel> conditionalModels = new List<IConditionalModel>();
|
||||
conditionalModels.Add(new ConditionalModel()
|
||||
{
|
||||
FieldName = thisFkColumn.DbColumnName,
|
||||
FieldValue = string.Join(",", ids.Distinct()),
|
||||
ConditionalType = ConditionalType.In,
|
||||
CSharpTypeName = thisFkColumn.PropertyName
|
||||
});
|
||||
var sqlObj = _Context.Queryable<object>().SqlBuilder.ConditionalModelToSql(conditionalModels);
|
||||
this._Context.Updateable<object>()
|
||||
.AS(thisEntity.DbTableName)
|
||||
.Where(sqlObj.Key, sqlObj.Value)
|
||||
.SetColumns(locgicColumn.DbColumnName, true)
|
||||
.ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._Context.Deleteable<object>()
|
||||
.AS(thisEntity.DbTableName)
|
||||
.In(thisFkColumn.DbColumnName, ids.Distinct().ToList()).ExecuteCommand();
|
||||
}
|
||||
_NavigateType = NavigateType.OneToMany;
|
||||
InsertDatas(children, thisPkColumn);
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ namespace SqlSugar
|
||||
public bool ManyToManyIsUpdateA { get; set; }
|
||||
public bool ManyToManyIsUpdateB { get; set; }
|
||||
public bool OneToManyDeleteAll { get; set; }
|
||||
public bool OneToManyEnableLogicDelete { get; set; }
|
||||
public Expression RootFunc { get; set; }
|
||||
public Expression CurrentFunc { get; set; }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user