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 { #nullable enable public class CrudWellRelatedServiceBase : CrudServiceBase, ICrudWellRelatedService where TDto : AsbCloudApp.Data.IId, AsbCloudApp.Data.IWellRelated where TEntity : class, IId, IWellRelated { public CrudWellRelatedServiceBase(IAsbCloudDbContext context) : base(context) { } public CrudWellRelatedServiceBase(IAsbCloudDbContext dbContext, ISet includes) : base(dbContext, includes) { } public CrudWellRelatedServiceBase(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) .ToListAsync(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)) .ToListAsync(token); var dtos = entities.Select(Convert).ToList(); return dtos; } } #nullable disable }