Home > OS >  Asp.NetCore - How To return tuple list from two tables?
Asp.NetCore - How To return tuple list from two tables?

Time:01-27

I have two tables, I want to return the value of the first table and the name of the table,Tables are related,I used the following code but it has an error?

public async Task<Tuple<Guid,string>> GetProductionsHorse()
{         
    return  await _context.Horses.Include(h => h.Production)
                          .Where(h => !h.IsRemove && h.IsAccept == 1)
                          .Select(p => new Tuple<Guid,string>(p.ProductionId, p.Production.Title))
                          .ToListAsync();
}

enter image description here

Can I access both values ​​if I return the value?

CodePudding user response:

Your method is declared as returning a single Tuple<Guid,string>. You are trying to return a List<Tuple<Guid,string>>, which is not the same thing.

Update your method signature to match the return value:

public async Task<List<Tuple<Guid,string>>> GetProductionsHorse()
  •  Tags:  
  • Related