[성현모] DB 예외처리 추가, UI 사이즈 조정
This commit is contained in:
@ -12,7 +12,7 @@ namespace SystemX.Core.Services
|
||||
{
|
||||
public class DbContextProvider
|
||||
{
|
||||
public Dictionary<string, DataBase> DBDictionary { get; private set; } = new Dictionary<string, DataBase>();
|
||||
public Dictionary<int, DataBase> DBDictionary { get; private set; } = new Dictionary<int, DataBase>();
|
||||
|
||||
public void SetDBList(IList<DataBase>? DBList)
|
||||
{
|
||||
@ -20,18 +20,18 @@ namespace SystemX.Core.Services
|
||||
{
|
||||
foreach (var db in DBList)
|
||||
{
|
||||
if (DBDictionary.ContainsKey($"{db.DBName}") == false)
|
||||
DBDictionary.Add($"{db.DBName}", db);
|
||||
if (DBDictionary.ContainsKey(db.DBID) == false)
|
||||
DBDictionary.Add(db.DBID, db);
|
||||
else
|
||||
LogXnet.WriteLine($"Exist key DB Dictionary {db.DBName}", LogXLabel.Error);
|
||||
LogXnet.WriteLine($"Exist key DB Dictionary {db.DBID}", LogXLabel.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 또는 context 직접 반환 (주의: caller가 Dispose 해야 함)
|
||||
public TContext? GetDBContext<TContext>(string dbName) where TContext : DbContext
|
||||
public TContext? GetDBContext<TContext>(int dbID) where TContext : DbContext
|
||||
{
|
||||
if(DBDictionary.TryGetValue(dbName, out var db) == true)
|
||||
if(DBDictionary.TryGetValue(dbID, out var db) == true)
|
||||
{
|
||||
var optionsBuilder = new DbContextOptionsBuilder<TContext>();
|
||||
optionsBuilder.UseSqlServer(db.ConvertToConnectionString());
|
||||
|
||||
Reference in New Issue
Block a user