C
Join ServerC#
help
❔ rename tuple
VJVINI JR12/13/2022
public async Task<(List<SalesReportEntity>, int totalSales)> GetAllSalesReportAsync(int companyId, int? SalesPage, int? Limitpage, DateTime? StartDate, DateTime? EndDate)
{
return (sales, sales.Count());
}
obs: I cut off some lines
is returning
item1: [{…}]
item2: 1
How can I rename it to sales and totalSales
AAngius12/13/2022
I'd probably just use a record here instead of a tuple
AAngius12/13/2022
But
return (sales: sales, totalSales: sales.Count())
should workAAngius12/13/2022
With the return type being
Task<(List<SalesReportEntity> sales, int totalSales)>
CCyberrex12/13/2022
this not necessary actually, if you specify the names in the return type
VJVINI JR12/13/2022
public async Task<(List<SalesReportEntity>allSales, int totalSales)> GetAllSalesReportAsync(){
return (allSales: sales, totalSales: sales.Count());
}
wont change :-:
VJVINI JR12/13/2022

CCyberrex12/13/2022
huh
AAngius12/13/2022
I guess STJ doesn't serialize named tuples
AAngius12/13/2022
Thankfully, solution is simple: just use a record
VJVINI JR12/13/2022
you right
VJVINI JR12/13/2022

VJVINI JR12/13/2022
return new SalesResume(sales, sales.Count());
VJVINI JR12/13/2022
idk if I did best way

AAngius12/13/2022
I'd just keep the record next to the method tbh, no need to make a whole separate file for it
AAngius12/13/2022
But, sure, it works either way
VJVINI JR12/13/2022
Interface need to be typed as well
VJVINI JR12/13/2022
namespace Epilefinho.Domain.Repositories
{
public interface ISaleRepository
{
Task<SalesResume> GetAllSalesReportAsync(int idCompany, int? NumberPage, int? Limitpage, DateTime? StartDate, DateTime? EndDate);
}
}
VJVINI JR12/13/2022
I'd prefer but I couldnt
AAngius12/13/2022
Yeah, understandable
VJVINI JR12/13/2022
thanks
AAccord12/14/2022
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.