forked from ddrilling/AsbCloudServer
Merge pull request 'Рефакторинг базового репозитория. Фикс обновления ГГД' (#267) from feature/refactoring_repository_base into dev
Reviewed-on: http://test.digitaldrilling.ru:8080/DDrilling/AsbCloudServer/pulls/267
This commit is contained in:
commit
87d03e5621
@ -133,18 +133,22 @@ namespace AsbCloudInfrastructure.Repository
|
||||
if (ids.Length != dtos.Count())
|
||||
throw new ArgumentInvalidException(nameof(dtos), "Все записи должны иметь уникальные Id");
|
||||
|
||||
var dbSet = dbContext.Set<TEntity>();
|
||||
|
||||
var existingEntitiesCount = await dbSet
|
||||
var existingEntitiesCount = await dbContext.Set<TEntity>()
|
||||
.Where(o => ids.Contains(o.Id))
|
||||
.CountAsync(token);
|
||||
|
||||
if (ids.Length != existingEntitiesCount)
|
||||
throw new ArgumentInvalidException(nameof(dtos), "Все записи должны существовать в БД");
|
||||
|
||||
var entities = dbContext.Set<TEntity>().Where(e => ids.Contains(e.Id));
|
||||
dbContext.Set<TEntity>().UpdateRange(entities);
|
||||
return await dbContext.SaveChangesAsync(token);
|
||||
var entities = dtos.Select(Convert);
|
||||
|
||||
var entries = entities.Select(entity => dbContext.Set<TEntity>().Update(entity)).ToList();
|
||||
|
||||
var affected = await dbContext.SaveChangesAsync(token);
|
||||
|
||||
entries.ForEach(entry => entry.State = EntityState.Detached);
|
||||
|
||||
return affected;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
@ -274,6 +274,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
dto.Timezone = GetTimezone(entity.Id);
|
||||
|
||||
dto.StartDate = dbContext.WellOperations.Where(e => e.IdType == WellOperation.IdOperationTypeFact)
|
||||
.AsNoTracking()
|
||||
.MinOrDefault(e => e.DateStart)?.ToRemoteDateTime(dto.Timezone.Hours);
|
||||
dto.WellType = entity.WellType.Caption;
|
||||
dto.Cluster = entity.Cluster.Caption;
|
||||
|
Loading…
Reference in New Issue
Block a user