0
votes

How can I post a request to a table generated from joining two tables in Web API, and return only required columns?

This is the code for that:

    public IActionResult GetAll()
    {
        try
        {
            var clients = _db.Clients
                             .Include(cl => cl.Projects)
                             .ToList();

            return Ok(clients);
        }
        catch(Exception ex) 
        {
            throw;
        }
    }
Is this code not working in some way? It's not clear to me what you're asking. - David
That's a lot of stuff to put in your title and I'm not sure what's relevant. Do you want to return only certain properties from your list clients? - phuzi
From the name of your method, it would imply that you do not have a POST at all, but rather a GET. - David L
Map your result to a class that has the desired shape - ErikEJ
... or .Select() it to an anonymous type before .ToList(). - phuzi