|
@@ -99,6 +99,10 @@ namespace OASystem.Infrastructure.Repositories
|
|
|
{
|
|
|
return await _sqlSugar.SqlQueryable<TEntity>(sql).ToListAsync();
|
|
|
}
|
|
|
+ public virtual List<TEntity> GetListBySqlWithNolock(string sql)
|
|
|
+ {
|
|
|
+ return _sqlSugar.SqlQueryable<TEntity>(sql).ToList();
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 添加返回主键Id
|
|
@@ -119,15 +123,15 @@ namespace OASystem.Infrastructure.Repositories
|
|
|
}
|
|
|
public virtual ISugarQueryable<TEntity> Query(Expression<Func<TEntity, bool>> exp)
|
|
|
{
|
|
|
- return _sqlSugar.Queryable<TEntity>().Where(a => !a.IsDel).Where(exp);
|
|
|
+ return _sqlSugar.Queryable<TEntity>().Where(a => a.IsDel < 1).Where(exp);
|
|
|
}
|
|
|
public virtual ISugarQueryable<TDto> QueryDto(Expression<Func<TEntity, bool>> exp)
|
|
|
{
|
|
|
- return _sqlSugar.Queryable<TEntity>().Where(a => !a.IsDel).Where(exp).Select<TDto>();
|
|
|
+ return _sqlSugar.Queryable<TEntity>().Where(a => a.IsDel < 1).Where(exp).Select<TDto>();
|
|
|
}
|
|
|
public virtual Task<TDto> GetDtoAsync(Expression<Func<TEntity, bool>> exp)
|
|
|
{
|
|
|
- return _sqlSugar.Queryable<TEntity>().Where(s => !s.IsDel).Where(exp).Select<TDto>().FirstAsync();
|
|
|
+ return _sqlSugar.Queryable<TEntity>().Where(s => s.IsDel < 1).Where(exp).Select<TDto>().FirstAsync();
|
|
|
}
|
|
|
public virtual Task<int> AddAsync(TEntity entity)
|
|
|
{
|
|
@@ -151,7 +155,7 @@ namespace OASystem.Infrastructure.Repositories
|
|
|
{
|
|
|
var result = await _sqlSugar.Updateable<TEntity>().Where(a => a.Id.Equals(id)).SetColumns(a => new TEntity()
|
|
|
{
|
|
|
- IsDel = true,
|
|
|
+ IsDel = 1,
|
|
|
DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
}).ExecuteCommandAsync();
|
|
|
return result > 0;
|
|
@@ -160,7 +164,7 @@ namespace OASystem.Infrastructure.Repositories
|
|
|
{
|
|
|
var result = await _sqlSugar.Updateable<TEntity>().Where(wherexp).SetColumns(a => new TEntity()
|
|
|
{
|
|
|
- IsDel = true,
|
|
|
+ IsDel = 1,
|
|
|
DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
}).ExecuteCommandAsync();
|
|
|
return result > 0;
|
|
@@ -169,15 +173,15 @@ namespace OASystem.Infrastructure.Repositories
|
|
|
#region 泛型CRUD
|
|
|
public virtual Task<bool> AnyAsync<T>(Expression<Func<T, bool>> exp) where T : EntityBase, new()
|
|
|
{
|
|
|
- return _sqlSugar.Queryable<T>().Where(s => !s.IsDel).AnyAsync(exp);
|
|
|
+ return _sqlSugar.Queryable<T>().Where(s => s.IsDel < 1).AnyAsync(exp);
|
|
|
}
|
|
|
public virtual Task<Dto> GetDtoAsync<T, Dto>(Expression<Func<T, bool>> exp) where T : EntityBase, new()
|
|
|
{
|
|
|
- return _sqlSugar.Queryable<T>().Where(s => !s.IsDel).Where(exp).Select<Dto>().FirstAsync();
|
|
|
+ return _sqlSugar.Queryable<T>().Where(s => s.IsDel < 1).Where(exp).Select<Dto>().FirstAsync();
|
|
|
}
|
|
|
public virtual ISugarQueryable<Dto> QueryDto<T, Dto>(Expression<Func<T, bool>> exp) where T : EntityBase, new()
|
|
|
{
|
|
|
- return _sqlSugar.Queryable<T>().Where(a => !a.IsDel).Where(exp).Select<Dto>();
|
|
|
+ return _sqlSugar.Queryable<T>().Where(a => a.IsDel < 1).Where(exp).Select<Dto>();
|
|
|
}
|
|
|
public virtual Task<int> AddAsync<T>(T entity) where T : EntityBase, new()
|
|
|
{
|
|
@@ -185,15 +189,15 @@ namespace OASystem.Infrastructure.Repositories
|
|
|
}
|
|
|
public virtual ISugarQueryable<T> Query<T>(Expression<Func<T, bool>> exp) where T : EntityBase, new()
|
|
|
{
|
|
|
- return _sqlSugar.Queryable<T>().Where(s => !s.IsDel).Where(exp);
|
|
|
+ return _sqlSugar.Queryable<T>().Where(s => s.IsDel < 1).Where(exp);
|
|
|
}
|
|
|
public virtual Task<T> GetAsync<T>(Expression<Func<T, bool>> exp) where T : EntityBase, new()
|
|
|
{
|
|
|
- return _sqlSugar.Queryable<T>().Where(s => !s.IsDel).Where(exp).FirstAsync();
|
|
|
+ return _sqlSugar.Queryable<T>().Where(s => s.IsDel < 1).Where(exp).FirstAsync();
|
|
|
}
|
|
|
public virtual T Get<T>(Expression<Func<T, bool>> exp) where T : EntityBase, new()
|
|
|
{
|
|
|
- return _sqlSugar.Queryable<T>().Where(s => !s.IsDel).Where(exp).First();
|
|
|
+ return _sqlSugar.Queryable<T>().Where(s => s.IsDel < 1).Where(exp).First();
|
|
|
}
|
|
|
|
|
|
public virtual async Task<bool> UpdateAsync<T>(Expression<Func<T, bool>> wherexp, Expression<Func<T, T>> upexp) where T : EntityBase, new()
|
|
@@ -210,7 +214,7 @@ namespace OASystem.Infrastructure.Repositories
|
|
|
{
|
|
|
var result = await _sqlSugar.Updateable<TEntity>().Where(a => a.Id.Equals(id)).SetColumns(a => new TEntity()
|
|
|
{
|
|
|
- IsDel = true,
|
|
|
+ IsDel = 1,
|
|
|
DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
}).ExecuteCommandAsync();
|
|
|
return result > 0;
|
|
@@ -219,7 +223,7 @@ namespace OASystem.Infrastructure.Repositories
|
|
|
{
|
|
|
var result = await _sqlSugar.Updateable<TEntity>().Where(wherexp).SetColumns(a => new TEntity()
|
|
|
{
|
|
|
- IsDel = true,
|
|
|
+ IsDel = 1,
|
|
|
DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
}).ExecuteCommandAsync();
|
|
|
return result > 0;
|