[성현모] EFCore 기능 추, dll 버전 추가
This commit is contained in:
55
Projects/HubX/HubX.Server/Services/UniqueKeyService.cs
Normal file
55
Projects/HubX/HubX.Server/Services/UniqueKeyService.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using DB.HubXDB;
|
||||
using HubX.Library.Http.Packet;
|
||||
using SystemX.Core.DB;
|
||||
|
||||
namespace HubX.Server.Services
|
||||
{
|
||||
public class UniqueKeyService
|
||||
{
|
||||
private readonly EFCoreService _efCoreService;
|
||||
|
||||
public UniqueKeyService(EFCoreService efCoreService)
|
||||
{
|
||||
_efCoreService = efCoreService;
|
||||
}
|
||||
|
||||
public async Task<Response_InsertUniqueKy> Request_InsertUniqueKey(Request_InsertUniqueKey request)
|
||||
{
|
||||
Response_InsertUniqueKy response = new Response_InsertUniqueKy();
|
||||
|
||||
var storage = new TStorage
|
||||
{
|
||||
CIdentity = request.Identity,
|
||||
CData1 = request.Data1,
|
||||
CData2 = request.Data2,
|
||||
CData3 = request.Data3,
|
||||
CData4 = request.Data4,
|
||||
CData5 = request.Data5,
|
||||
|
||||
CDateTime = DateTime.Now
|
||||
};
|
||||
|
||||
|
||||
bool transactionResult = true;
|
||||
bool isExist = false;
|
||||
var context = _efCoreService.GetDBContext<HubXContext>();
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
using (var transaction = await context.CreateTransactionAsync())
|
||||
{
|
||||
await context.AddAsync(storage);
|
||||
transactionResult = await context.CloseTransactionAsync(transaction);
|
||||
}
|
||||
}
|
||||
|
||||
//db error
|
||||
if (transactionResult == false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user