diff --git a/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/SqlSugarDbContext.cs b/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/SqlSugarDbContext.cs
index cdb050d8..5fa812af 100644
--- a/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/SqlSugarDbContext.cs
+++ b/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/SqlSugarDbContext.cs
@@ -57,12 +57,10 @@ namespace Yi.Framework.SqlSugarCore
connectionCreator.DataExecuted = DataExecuted;
connectionCreator.OnLogExecuting = OnLogExecuting;
connectionCreator.OnLogExecuted = OnLogExecuted;
- var currentConnection = GetCurrentConnectionString();
- var currentDbType = GetCurrentDbType();
SqlSugarClient = new SqlSugarClient(connectionCreator.Build(action: options =>
{
- options.ConnectionString = currentConnection;
-
+ options.ConnectionString = GetCurrentConnectionString();
+ options.DbType = GetCurrentDbType();
}));
connectionCreator.SetDbAop(SqlSugarClient);
}
diff --git a/Yi.Abp.Net8/module/tenant-management/Yi.Framework.TenantManagement.Application/TenantService.cs b/Yi.Abp.Net8/module/tenant-management/Yi.Framework.TenantManagement.Application/TenantService.cs
index 11979e9f..618bda62 100644
--- a/Yi.Abp.Net8/module/tenant-management/Yi.Framework.TenantManagement.Application/TenantService.cs
+++ b/Yi.Abp.Net8/module/tenant-management/Yi.Framework.TenantManagement.Application/TenantService.cs
@@ -18,11 +18,15 @@ namespace Yi.Framework.TenantManagement.Application
///
/// 租户管理
///
- public class TenantService : YiCrudAppService, ITenantService
+ public class TenantService :
+ YiCrudAppService, ITenantService
{
private ISqlSugarRepository _repository;
private IDataSeeder _dataSeeder;
- public TenantService(ISqlSugarRepository repository, IDataSeeder dataSeeder) : base(repository)
+
+ public TenantService(ISqlSugarRepository repository, IDataSeeder dataSeeder) :
+ base(repository)
{
_repository = repository;
_dataSeeder = dataSeeder;
@@ -47,9 +51,11 @@ namespace Yi.Framework.TenantManagement.Application
{
RefAsync total = 0;
- var entities = await _repository._DbQueryable.WhereIF(!string.IsNullOrEmpty(input.Name), x => x.Name.Contains(input.Name!))
- .WhereIF(input.StartTime is not null && input.EndTime is not null, x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
- .ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
+ var entities = await _repository._DbQueryable
+ .WhereIF(!string.IsNullOrEmpty(input.Name), x => x.Name.Contains(input.Name!))
+ .WhereIF(input.StartTime is not null && input.EndTime is not null,
+ x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
+ .ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
return new PagedResultDto(total, await MapToGetListOutputDtosAsync(entities));
}
@@ -75,6 +81,7 @@ namespace Yi.Framework.TenantManagement.Application
{
throw new UserFriendlyException("创建失败,当前租户已存在");
}
+
return await base.CreateAsync(input);
}
@@ -118,9 +125,8 @@ namespace Yi.Framework.TenantManagement.Application
using (CurrentTenant.Change(id))
{
await CodeFirst(this.LazyServiceProvider);
- await _dataSeeder.SeedAsync(id);
+ await _dataSeeder.SeedAsync(id);
}
-
}
private async Task CodeFirst(IServiceProvider service)
@@ -134,27 +140,24 @@ namespace Yi.Framework.TenantManagement.Application
db = await _repository.GetDbContextAsync();
//尝试创建数据库
db.DbMaintenance.CreateDatabase();
- await uow.CompleteAsync();
+
+ List types = new List();
+ foreach (var module in moduleContainer.Modules)
+ {
+ types.AddRange(module.Assembly.GetTypes()
+ .Where(x => x.GetCustomAttribute() == null)
+ .Where(x => x.GetCustomAttribute() != null)
+ .Where(x => x.GetCustomAttribute() is null)
+ .Where(x => x.GetCustomAttribute() is null));
+ }
+
+ if (types.Count > 0)
+ {
+ db.CodeFirst.InitTables(types.ToArray());
+ }
+
+ await uow.CompleteAsync();
}
-
-
-
-
-
- List types = new List();
- foreach (var module in moduleContainer.Modules)
- {
- types.AddRange(module.Assembly.GetTypes()
- .Where(x => x.GetCustomAttribute() == null)
- .Where(x => x.GetCustomAttribute() != null)
- .Where(x=>x.GetCustomAttribute() is null)
- .Where(x => x.GetCustomAttribute() is null));
- }
- if (types.Count > 0)
- {
- db.CopyNew().CodeFirst.InitTables(types.ToArray());
- }
-
}
}
-}
+}
\ No newline at end of file