Browse Source

SimpleClient Add InsertOrUpdate

pull/19/head
sunkaixuan 2 years ago
parent
commit
147b3b2751
  1. 4
      Src/Asp.Net/SqlSugar/Interface/ISimpleClient.cs
  2. 18
      Src/Asp.Net/SqlSugar/SimpleClient.cs

4
Src/Asp.Net/SqlSugar/Interface/ISimpleClient.cs

@ -36,6 +36,8 @@ namespace SqlSugar
T GetSingle(Expression<Func<T, bool>> whereExpression);
T GetFirst(Expression<Func<T, bool>> whereExpression);
bool Insert(T insertObj);
bool InsertOrUpdate(T data);
bool InsertOrUpdate(List<T> datas);
bool InsertRange(List<T> insertObjs);
bool InsertRange(T[] insertObjs);
int InsertReturnIdentity(T insertObj);
@ -69,6 +71,8 @@ namespace SqlSugar
Task<T> GetSingleAsync(Expression<Func<T, bool>> whereExpression);
Task<T> GetFirstAsync(Expression<Func<T, bool>> whereExpression);
Task<bool> InsertAsync(T insertObj);
Task<bool> InsertOrUpdateAsync(T data);
Task<bool> InsertOrUpdateAsync(List<T> datas);
Task<bool> InsertRangeAsync(List<T> insertObjs);
Task<bool> InsertRangeAsync(T[] insertObjs);
Task<int> InsertReturnIdentityAsync(T insertObj);

18
Src/Asp.Net/SqlSugar/SimpleClient.cs

@ -148,6 +148,16 @@ namespace SqlSugar
{
return this.Context.Insertable(insertObj).ExecuteCommand() > 0;
}
public virtual bool InsertOrUpdate(T data)
{
return this.Context.Storageable(data).ExecuteCommand() > 0;
}
public virtual bool InsertOrUpdate(List<T> datas)
{
return this.Context.Storageable(datas).ExecuteCommand() > 0;
}
public virtual int InsertReturnIdentity(T insertObj)
{
return this.Context.Insertable(insertObj).ExecuteReturnIdentity();
@ -278,6 +288,14 @@ namespace SqlSugar
return Context.Queryable<T>().Where(whereExpression).CountAsync();
}
public virtual async Task<bool> InsertOrUpdateAsync(T data)
{
return await this.Context.Storageable(data).ExecuteCommandAsync() > 0;
}
public virtual async Task<bool> InsertOrUpdateAsync(List<T> datas)
{
return await this.Context.Storageable(datas).ExecuteCommandAsync() > 0;
}
public virtual async Task<bool> InsertAsync(T insertObj)
{
return await this.Context.Insertable(insertObj).ExecuteCommandAsync() > 0;

Loading…
Cancel
Save