|
@@ -12,7 +12,7 @@ namespace Admin.NET.Core;
|
|
|
/// SqlSugar 实体仓储
|
|
/// SqlSugar 实体仓储
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <typeparam name="T"></typeparam>
|
|
/// <typeparam name="T"></typeparam>
|
|
|
-public class SqlSugarRepository<T> : SimpleClient<T> where T : class, new()
|
|
|
|
|
|
|
+public class SqlSugarRepository<T> : SimpleClient<T>, ISqlSugarRepository<T> where T : class, new()
|
|
|
{
|
|
{
|
|
|
public SqlSugarRepository()
|
|
public SqlSugarRepository()
|
|
|
{
|
|
{
|
|
@@ -47,4 +47,50 @@ public class SqlSugarRepository<T> : SimpleClient<T> where T : class, new()
|
|
|
if (sqlSugarScopeProviderTenant == null) return;
|
|
if (sqlSugarScopeProviderTenant == null) return;
|
|
|
base.Context = sqlSugarScopeProviderTenant;
|
|
base.Context = sqlSugarScopeProviderTenant;
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
|
|
+ #region 分表操作
|
|
|
|
|
+ public async Task<bool> SplitTableInsertAsync(T input)
|
|
|
|
|
+ {
|
|
|
|
|
+ return await base.AsInsertable(input).SplitTable().ExecuteCommandAsync() > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ public async Task<bool> SplitTableInsertAsync(List<T> input)
|
|
|
|
|
+ {
|
|
|
|
|
+ return await base.AsInsertable(input).SplitTable().ExecuteCommandAsync() > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ public async Task<bool> SplitTableUpdateAsync(T input)
|
|
|
|
|
+ {
|
|
|
|
|
+ return await base.AsUpdateable(input).SplitTable().ExecuteCommandAsync() > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ public async Task<bool> SplitTableUpdateAsync(List<T> input)
|
|
|
|
|
+ {
|
|
|
|
|
+ return await base.AsUpdateable(input).SplitTable().ExecuteCommandAsync() > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ public async Task<bool> SplitTableDeleteableAsync(T input)
|
|
|
|
|
+ {
|
|
|
|
|
+ return await base.Context.Deleteable(input).SplitTable().ExecuteCommandAsync() > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ public async Task<bool> SplitTableDeleteableAsync(List<T> input)
|
|
|
|
|
+ {
|
|
|
|
|
+ return await base.Context.Deleteable(input).SplitTable().ExecuteCommandAsync() > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ public Task<T> SplitTableGetFirstAsync(Expression<Func<T, bool>> whereExpression)
|
|
|
|
|
+ {
|
|
|
|
|
+ return base.AsQueryable().SplitTable().FirstAsync(whereExpression);
|
|
|
|
|
+ }
|
|
|
|
|
+ public Task<bool> SplitTableIsAnyAsync(Expression<Func<T, bool>> whereExpression)
|
|
|
|
|
+ {
|
|
|
|
|
+ return base.Context.Queryable<T>().Where(whereExpression).SplitTable().AnyAsync();
|
|
|
|
|
+ }
|
|
|
|
|
+ public Task<List<T>> SplitTableGetListAsync()
|
|
|
|
|
+ {
|
|
|
|
|
+ return Context.Queryable<T>().SplitTable().ToListAsync();
|
|
|
|
|
+ }
|
|
|
|
|
+ public Task<List<T>> SplitTableGetListAsync(Expression<Func<T, bool>> whereExpression)
|
|
|
|
|
+ {
|
|
|
|
|
+ return Context.Queryable<T>().Where(whereExpression).SplitTable().ToListAsync();
|
|
|
|
|
+ }
|
|
|
|
|
+ public Task<List<T>> SplitTableGetListAsync(Expression<Func<T, bool>> whereExpression, string[] tableNames)
|
|
|
|
|
+ {
|
|
|
|
|
+ return Context.Queryable<T>().Where(whereExpression).SplitTable(t => t.InTableNames(tableNames)).ToListAsync();
|
|
|
|
|
+ }
|
|
|
|
|
+ #endregion
|
|
|
|
|
+}
|