Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class CountriesController: ControllerBase
private readonly ApplicationDbContext context;
public CountriesController(ApplicationDbContext context)
this.context = context;
public async Task<ActionResult<List<Country>>> Get()
return await context.Countries.OrderBy(x => x.Name).ToListAsync();
public async Task<List<State>> GetStates(int countryId)
return await context.States.Where(x => x.CountryId == countryId)
.OrderBy(x => x.Name).ToListAsync();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.