Extenso.AspNetCore.OData
9.4.0
dotnet add package Extenso.AspNetCore.OData --version 9.4.0
NuGet\Install-Package Extenso.AspNetCore.OData -Version 9.4.0
<PackageReference Include="Extenso.AspNetCore.OData" Version="9.4.0" />
<PackageVersion Include="Extenso.AspNetCore.OData" Version="9.4.0" />
<PackageReference Include="Extenso.AspNetCore.OData" />
paket add Extenso.AspNetCore.OData --version 9.4.0
#r "nuget: Extenso.AspNetCore.OData, 9.4.0"
#:package Extenso.AspNetCore.OData@9.4.0
#addin nuget:?package=Extenso.AspNetCore.OData&version=9.4.0
#tool nuget:?package=Extenso.AspNetCore.OData&version=9.4.0
<img src="https://github.com/gordon-matt/Extenso/blob/master/_Misc/ExtensoLogo.png" alt="Logo" width="250" />
Extenso.AspNetCore.OData
Intro
This package contains a GenericODataController
, as well as a GenericMappedODataController
if working from DAOs instead of entities is required.
To get started, see the Demo project in this repo, which has a fully working CRUD demo using OData, KendoGrid and KnockoutJS.
Getting Started
This package is dependant on the "Extenso.Data.Entity" package, which provides the IRepository<T>
and IMappedRepository<T, TModel>
interfaces required.
Follow the instructions in the Extenso.Data.Entity package to get your IDbContextFactory
and repositories registered for dependency injection.
Once that is done, you can use the GenericODataController
or GenericMappedODataController
in your ASP.NET Core application as follows:
Setup an IODataRegistrar
to register your OData controllers and models:
public class ODataRegistrar : IODataRegistrar
{
public void Register(ODataOptions options)
{
ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<Person>("PersonApi");
options.AddRouteComponents("odata", builder.GetEdmModel());
}
}
NOTE: Using an IODataRegistrar
is not required, but it is a good way to keep your OData configuration clean and organized. Moreover, it's
helpful if you have multiple projects each with their own OData controllers that need to be registered.
services.AddSingleton<IODataRegistrar, ODataRegistrar>();
services.AddOData((options, serviceProvider) =>
{
options.Select().Expand().Filter().OrderBy().SetMaxTop(null).Count();
// You may have many IODataRegistrar implementations in Razor Class Libraries or other projects.
var registrars = serviceProvider.GetRequiredService<IEnumerable<IODataRegistrar>>();
foreach (var registrar in registrars)
{
registrar.Register(options);
}
});
And now all you need to do is create your OData controllers. Example:
public class PersonApiController : BaseODataController<Person, int>
{
public PersonApiController(IAuthorizationService authorizationService, IRepository<Person> repository)
: base(authorizationService, repository)
{
}
protected override int GetId(Person entity) => entity.Id;
protected override void SetNewId(Person entity)
{
// Don't try to set the ID here unless it's not auto incremented, such as a GUID, for example.
}
}
As simple as that.. you now have a fully functional OData API for your Person
entity. If you have a grid that supports OData out of the box, such as KendoGrid, you can now bind it to this API very easily:
self.apiUrl = "/odata/PersonApi";
$("#grid").kendoGrid({
data: null,
dataSource: {
type: 'odata-v4',
transport: {
read: self.apiUrl
},
// etc..
Take a look at the demo projects for more details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Extenso.Data.Entity (>= 9.4.0)
- Microsoft.AspNetCore.OData (>= 9.3.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Extenso.AspNetCore.OData:
Package | Downloads |
---|---|
MantleFramework.Web
Mantle - Web. Includes admin pages for Membership, Localization, Configuration, Tenants, Scheduled Tasks, etc. Also includes many extensions and helper classes. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
9.4.0 | 137 | 6/16/2025 |
9.3.1 | 153 | 6/2/2025 |
9.3.0 | 112 | 5/25/2025 |
9.2.0 | 95 | 5/3/2025 |
9.1.0 | 203 | 3/23/2025 |
9.0.0 | 162 | 1/4/2025 |
8.0.0 | 149 | 5/15/2024 |
7.0.2 | 234 | 8/19/2023 |
7.0.1 | 231 | 6/12/2023 |
7.0.0 | 378 | 11/27/2022 |
6.1.0 | 369 | 11/18/2022 |
6.0.3 | 1,928 | 5/21/2022 |
6.0.2 | 612 | 4/1/2022 |
6.0.1 | 656 | 2/21/2022 |
6.0.0 | 574 | 1/14/2022 |
5.0.0 | 643 | 12/7/2020 |
3.1.0 | 710 | 6/15/2020 |
2.0.0 | 710 | 2/24/2020 |
1.2.0 | 865 | 2/27/2019 |
1.1.3 | 918 | 10/26/2018 |
1.1.2 | 1,292 | 6/30/2018 |
1.1.0 | 1,238 | 6/20/2018 |
1.0.1 | 1,371 | 5/17/2018 |
1.0.0 | 1,104 | 5/16/2018 |