[성현모] Select기능 추가, ReadUncommitted level 적용
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -74,9 +75,9 @@ namespace SystemX.Core.DB
|
||||
#endregion
|
||||
|
||||
#region Transaction Async
|
||||
public static async Task<IDbContextTransaction> CreateTransactionAsync(this DbContext dbContext)
|
||||
public static async Task<IDbContextTransaction> CreateTransactionAsync(this DbContext dbContext, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted)
|
||||
{
|
||||
return await dbContext.Database.BeginTransactionAsync();
|
||||
return await dbContext.Database.BeginTransactionAsync(isolationLevel);
|
||||
}
|
||||
|
||||
public static async Task<bool> CloseTransactionAsync(this DbContext dbContext, IDbContextTransaction transaction)
|
||||
|
||||
@ -1,64 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Core.Config.Model;
|
||||
|
||||
namespace SystemX.Core.DB
|
||||
{
|
||||
public class EFCore
|
||||
{
|
||||
private readonly Dictionary<string, DbContext> DicDbContext = new Dictionary<string, DbContext>();
|
||||
|
||||
public EFCore()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
#region Initialize DBContext
|
||||
private void InitializeDB<TDBContext>() where TDBContext : DbContext, new()
|
||||
{
|
||||
//if (dbList is not null)
|
||||
//{
|
||||
// foreach (var db in dbList)
|
||||
// {
|
||||
// if (typeof(VpkiAccountDbContext).Name == db.DBContext)
|
||||
// {
|
||||
// CreateDBContext<TDBContext>(db);
|
||||
// }
|
||||
// else if (typeof(VpkiDataDbContext).Name == db.DBContext)
|
||||
// {
|
||||
// CreateDBContext<VpkiDataDbContext>(db);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
private void CreateDBContext<TDBContext>(DataBase? dbConfig) where TDBContext : DbContext, new()
|
||||
{
|
||||
//var connectionString = dbConfig?.ConvertToConnectionString();
|
||||
|
||||
//var dbContext = new TDBContext();
|
||||
//dbContext.Database.SetConnectionString($"{connectionString}");
|
||||
|
||||
//if (dbContext is not null)
|
||||
// DicDbContext.Add($"{dbConfig?.DBContext}_{dbConfig?.DBID}", dbContext);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public TDBContext? GetDBContext<TDBContext>(int dbID = 1) where TDBContext : DbContext
|
||||
{
|
||||
TDBContext? dBContext = default;
|
||||
|
||||
var dbContextType = typeof(TDBContext);
|
||||
if (DicDbContext.TryGetValue($"{dbContextType.Name}_{dbID}", out var context) == true)
|
||||
{
|
||||
dBContext = context as TDBContext;
|
||||
}
|
||||
|
||||
return dBContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,7 +17,9 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="log4net" Version="3.0.4" />
|
||||
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.15" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.15" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user