Reputation:
I just filter all record but I can`t filter one record.
[HttpGet("GetContact")]
public async Task<ActionResult<IEnumerable<ContactEm>>> GetContactEms([FromQuery(Name = "top")] int top, [FromQuery(Name = "$skip")] int skip, [FromQuery(Name = "$orderby")] string orderny, [FromQuery(Name = "$filter")] string filter)
{
return await _context.ContactEms.ToListAsync();
}
Upvotes: 0
Views: 158
Reputation: 2185
For the "switching on" filtering feature, supported by OData ($filter=...)
you should create a controller, inherited from ODataController
, with [EnableQuery] attribute on the method. Consider using official manual for a detailed walkthrough.
In your case, it should be something like:
public class ContactEmsController : ODataController
{
...
[EnableQuery]
public IQueryable<ContactEm> Get()
{
return _context.ContactEms;
}
}
Upvotes: 1