Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Asp.NetCore – How To return tuple list from two tables?

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading