public FacturasDto ObtenerFacturas(int pageSize, int page) { try { var t1 = Task.Run(() => _facturaService.GetAll(pageSize, page)); var t2 = Task.Run(() => _facturaService.Count()); Task.WhenAll(t1, t2); var list = t1.Result; var total = t2.Result; //here is where we can use AutoMapper return(new FacturasDto { Facturas = list.Select(m => new FacturaDto { Folio = m.Folio, LugarExpedicion = m.LugarExpedicion, FechaExpedicion = m.FechaExpedicion, RfcEmisor = m.EmisorRfc, RfcReceptor = m.ReceptorRfc, }), Paginacion = new PaginacionDto { CurrrentPage = page, PageSize = pageSize, TotalRecords = total, TotalPages = (int)(total / pageSize) } }); } catch (Exception e) { throw new FaultException(e.InnerException?.Message ?? e.Message); } }