Implement parsing
This commit is contained in:
@ -27,6 +27,12 @@ namespace Hcs.WebApp.Services
|
||||
return fileToParse;
|
||||
}
|
||||
|
||||
public async Task<FileToParse> GetFileToParseByOperationIdAsync(int operationId)
|
||||
{
|
||||
using var context = GetNewContext();
|
||||
return await GetFileToParseByOperationIdAsync(context, operationId);
|
||||
}
|
||||
|
||||
public async Task<FileToParse> GetFileToParseByOperationIdAsync(HcsDbContext context, int operationId)
|
||||
{
|
||||
return await context.FilesToParse.SingleAsync(x => x.LastParseOperationId == operationId);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Hcs.WebApp.Data.Hcs;
|
||||
using EFCore.BulkExtensions;
|
||||
using Hcs.WebApp.Data.Hcs;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hcs.WebApp.Services
|
||||
@ -10,5 +11,21 @@ namespace Hcs.WebApp.Services
|
||||
using var context = GetNewContext();
|
||||
return await context.Houses.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task UpsertHouses(IEnumerable<House> houses)
|
||||
{
|
||||
using var context = GetNewContext();
|
||||
await context.BulkInsertOrUpdateAsync(houses, new BulkConfig()
|
||||
{
|
||||
PropertiesToExcludeOnUpdate =
|
||||
[
|
||||
nameof(House.ThirdPartyId)
|
||||
],
|
||||
UpdateByProperties =
|
||||
[
|
||||
nameof(House.HcsId)
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user