using AsbCloudApp.Services; using AsbCloudDb.Model; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; namespace AsbCloudInfrastructure.Repository; public class CrudWellRelatedRepositoryBase : CrudRepositoryBase, IRepositoryWellRelated where TDto : AsbCloudApp.Data.IId, AsbCloudApp.Data.IWellRelated where TEntity : class, IId, IWellRelated { public CrudWellRelatedRepositoryBase(IAsbCloudDbContext context) : base(context) { } public CrudWellRelatedRepositoryBase(IAsbCloudDbContext context, Func, IQueryable> makeQuery) : base(context, makeQuery) { } public async Task> GetByIdWellAsync(int idWell, CancellationToken token) { var entities = await GetQuery() .Where(e => e.IdWell == idWell) .AsNoTracking() .ToArrayAsync(token); var dtos = entities.Select(Convert).ToList(); return dtos; } public async Task> GetByIdWellAsync(IEnumerable idsWells, CancellationToken token) { if (!idsWells.Any()) return Enumerable.Empty(); var entities = await GetQuery() .Where(e => idsWells.Contains(e.IdWell)) .AsNoTracking() .ToArrayAsync(token); var dtos = entities.Select(Convert).ToList(); return dtos; } }