Skip to content

Instantly share code, notes, and snippets.

@adlerpagliarini
Created April 15, 2019 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adlerpagliarini/1e780f383db911a663ccaf5a5a68eb99 to your computer and use it in GitHub Desktop.
Save adlerpagliarini/1e780f383db911a663ccaf5a5a68eb99 to your computer and use it in GitHub Desktop.
...
public class DeveloperController : ControllerBase
{
...
[HttpGet]
[Route("{id}")]
// 4. Enable OData
[EnableQuery()]
public async Task<ActionResult<Developer>> Get(int id)
{
var developer = await _context.Developer.FindAsync(id);
if (developer == null) return NotFound();
return developer;
}
[HttpGet]
// 4. Enable OData
[EnableQuery()]
public IEnumerable<Developer> Get() => _context.Developer.AsQueryable();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment