mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
update BaseEntity
This commit is contained in:
@ -83,7 +83,8 @@ namespace FreeSql
|
||||
if (Repository == null)
|
||||
return Orm.Update<TEntity>(this as TEntity)
|
||||
.WithTransaction(_resolveUow?.Invoke()?.GetOrBeginTransaction())
|
||||
.Set(a => (a as BaseEntity).IsDeleted, IsDeleted = value).ExecuteAffrows() == 1;
|
||||
.Set(a => (a as BaseEntity).IsDeleted, IsDeleted = value)
|
||||
.ExecuteAffrows() == 1;
|
||||
|
||||
IsDeleted = value;
|
||||
Repository.UnitOfWork = _resolveUow?.Invoke();
|
||||
@ -102,7 +103,9 @@ namespace FreeSql
|
||||
return UpdateIsDeleted(true);
|
||||
|
||||
if (Repository == null)
|
||||
return Orm.Delete<TEntity>(this as TEntity).ExecuteAffrows() == 1;
|
||||
return Orm.Delete<TEntity>(this as TEntity)
|
||||
.WithTransaction(_resolveUow?.Invoke()?.GetOrBeginTransaction())
|
||||
.ExecuteAffrows() == 1;
|
||||
|
||||
Repository.UnitOfWork = _resolveUow?.Invoke();
|
||||
return Repository.Delete(this as TEntity) == 1;
|
||||
@ -126,7 +129,8 @@ namespace FreeSql
|
||||
if (Repository == null)
|
||||
return Orm.Update<TEntity>()
|
||||
.WithTransaction(_resolveUow?.Invoke()?.GetOrBeginTransaction())
|
||||
.SetSource(this as TEntity).ExecuteAffrows() == 1;
|
||||
.SetSource(this as TEntity)
|
||||
.ExecuteAffrows() == 1;
|
||||
|
||||
Repository.UnitOfWork = _resolveUow?.Invoke();
|
||||
return Repository.Update(this as TEntity) == 1;
|
||||
|
@ -70,7 +70,8 @@ namespace FreeSql
|
||||
if (Repository == null)
|
||||
return await Orm.Update<TEntity>(this as TEntity)
|
||||
.WithTransaction(_resolveUow?.Invoke()?.GetOrBeginTransaction())
|
||||
.Set(a => (a as BaseEntity).IsDeleted, IsDeleted = value).ExecuteAffrowsAsync() == 1;
|
||||
.Set(a => (a as BaseEntity).IsDeleted, IsDeleted = value)
|
||||
.ExecuteAffrowsAsync() == 1;
|
||||
|
||||
IsDeleted = value;
|
||||
Repository.UnitOfWork = _resolveUow?.Invoke();
|
||||
@ -89,7 +90,9 @@ namespace FreeSql
|
||||
return await UpdateIsDeletedAsync(true);
|
||||
|
||||
if (Repository == null)
|
||||
return await Orm.Delete<TEntity>(this as TEntity).ExecuteAffrowsAsync() == 1;
|
||||
return await Orm.Delete<TEntity>(this as TEntity)
|
||||
.WithTransaction(_resolveUow?.Invoke()?.GetOrBeginTransaction())
|
||||
.ExecuteAffrowsAsync() == 1;
|
||||
|
||||
Repository.UnitOfWork = _resolveUow?.Invoke();
|
||||
return await Repository.DeleteAsync(this as TEntity) == 1;
|
||||
@ -113,7 +116,8 @@ namespace FreeSql
|
||||
if (Repository == null)
|
||||
return await Orm.Update<TEntity>()
|
||||
.WithTransaction(_resolveUow?.Invoke()?.GetOrBeginTransaction())
|
||||
.SetSource(this as TEntity).ExecuteAffrowsAsync() == 1;
|
||||
.SetSource(this as TEntity)
|
||||
.ExecuteAffrowsAsync() == 1;
|
||||
|
||||
Repository.UnitOfWork = _resolveUow?.Invoke();
|
||||
return await Repository.UpdateAsync(this as TEntity) == 1;
|
||||
|
@ -26,11 +26,7 @@ namespace FreeSql
|
||||
|
||||
public static IFreeSql Orm => _resoleOrm?.Invoke() ?? throw new Exception("BaseEntity.Initialization 初始化错误,获取到 IFreeSql 是 null");
|
||||
|
||||
public static void Initialization(IFreeSql fsql, Func<IUnitOfWork> resolveUow)
|
||||
{
|
||||
fsql.Aop.CurdBefore += (s, e) => Trace.WriteLine($"\r\n线程{Thread.CurrentThread.ManagedThreadId}: {e.Sql}\r\n");
|
||||
Initialization(() => fsql, resolveUow);
|
||||
}
|
||||
public static void Initialization(IFreeSql fsql, Func<IUnitOfWork> resolveUow) => Initialization(() => fsql, resolveUow);
|
||||
public static void Initialization(Func<IFreeSql> resoleOrm, Func<IUnitOfWork> resolveUow)
|
||||
{
|
||||
_resoleOrm = resoleOrm;
|
||||
|
Reference in New Issue
Block a user