// GET: odata/Employees public async Task<IHttpActionResult> GetEmployees(ODataQueryOptions<Employee> queryOptions) { IEnumerable<Employee> ret = null; // validate the query. try { queryOptions.Validate(_validationSettings); var data = new NortWindModel(); ret = data.Employees.ToList(); } catch (ODataException ex) { return BadRequest(ex.Message); } return Ok<IEnumerable<Employee>>(ret); //return StatusCode(HttpStatusCode.NotImplemented); }
// GET: odata/Employees(5) public async Task<IHttpActionResult> GetEmployee([FromODataUri] int key, ODataQueryOptions<Employee> queryOptions) { Employee ret = null; // validate the query. try { queryOptions.Validate(_validationSettings); var dbContext = new NortWindModel(); ret = dbContext.Employees.FirstOrDefault(x => x.EmployeeID == key); } catch (ODataException ex) { return BadRequest(ex.Message); } return Ok<Employee>(ret); //return StatusCode(HttpStatusCode.NotImplemented); }