From 88477dffdd0811a5613dba0aa1db4818bf4fd058 Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 19 Dec 2022 12:24:54 +0800 Subject: Develop secret api. v43 --- .../CrupestApi/CrupestApi.Commons/Crud/CrudService.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs') diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs index 184ac0a..27f0c85 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs @@ -12,9 +12,9 @@ public class CrudService : IDisposable where TEntity : class protected readonly EntityJsonHelper _jsonHelper; private readonly ILogger> _logger; - public CrudService(string? connectionName, ITableInfoFactory tableInfoFactory, IDbConnectionFactory dbConnectionFactory, EntityJsonHelper jsonHelper, ILoggerFactory loggerFactory) + public CrudService(ITableInfoFactory tableInfoFactory, IDbConnectionFactory dbConnectionFactory, EntityJsonHelper jsonHelper, ILoggerFactory loggerFactory) { - _connectionName = connectionName; + _connectionName = GetConnectionName(); _table = tableInfoFactory.Get(typeof(TEntity)); _dbConnection = dbConnectionFactory.Get(_connectionName); _jsonHelper = jsonHelper; @@ -23,6 +23,11 @@ public class CrudService : IDisposable where TEntity : class CheckDatabase(_dbConnection); } + protected virtual string GetConnectionName() + { + return typeof(TEntity).Name; + } + public EntityJsonHelper JsonHelper => _jsonHelper; protected virtual void CheckDatabase(IDbConnection dbConnection) @@ -33,7 +38,7 @@ public class CrudService : IDisposable where TEntity : class } } - private void DoInitializeDatabase(IDbConnection connection) + protected virtual void DoInitializeDatabase(IDbConnection connection) { using var transaction = connection.BeginTransaction(); connection.Execute(_table.GenerateCreateTableSql(), transaction: transaction); -- cgit v1.2.3