Skip to content

Instantly share code, notes, and snippets.

@gashupl
Created March 8, 2018 07:54
Show Gist options
  • Select an option

  • Save gashupl/a052688bea027a976d7f0f0f55a82bbd to your computer and use it in GitHub Desktop.

Select an option

Save gashupl/a052688bea027a976d7f0f0f55a82bbd to your computer and use it in GitHub Desktop.
public class ItemsController : ODataController
{
private readonly IItemsRepository itemsRepository;</code>
public ItemsController(IItemsRepository itemsRepository)
{
this.itemsRepository = itemsRepository;
}
[EnableQuery]
public IList Get()
{
return this.itemsRepository.GetItems().ToList();
}
[EnableQuery]
public SingleResult Get([FromODataUri] Guid key)
{
IQueryable result = itemsRepository.GetItems().Where(p =&gt; p.Id == key).AsQueryable();
return SingleResult.Create(result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment