mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 10:08:19 +08:00
SimpleClient Add InsertOrUpdate
This commit is contained in:
@@ -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);
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user