Kebechet.Api.OData 1.0.0

Prefix Reserved
dotnet add package Kebechet.Api.OData --version 1.0.0
                    
NuGet\Install-Package Kebechet.Api.OData -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Kebechet.Api.OData" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kebechet.Api.OData" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Kebechet.Api.OData" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Kebechet.Api.OData --version 1.0.0
                    
#r "nuget: Kebechet.Api.OData, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Kebechet.Api.OData@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Kebechet.Api.OData&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Kebechet.Api.OData&version=1.0.0
                    
Install as a Cake Tool

"Buy Me A Coffee"

Api.OData

NuGet Version NuGet Downloads Last updated Twitter

A lightweight library for applying OData query options ($filter, $orderby, $skip, $top, $select, $apply) to IQueryable<T> and IEnumerable<T> collections in ASP.NET Core applications.

Features

  • Apply OData query options from HTTP request to any collection
  • Fluent extension methods for IQueryable and IEnumerable
  • Configurable options (page size, ignored query options, null propagation)
  • IODataService interface for easy mocking/testing
  • Generic RegisterEntitiesFromAssemblies<TMarker>() - use your own marker interface
  • Full XML documentation for IntelliSense support

Installation

dotnet add package Kebechet.Api.OData

Usage

Setup

// Basic setup with default options
services.AddOData(builder =>
{
    builder.RegisterEntitiesFromAssemblies<IEntity>(typeof(MyEntity).Assembly);
});

// With manual type registration
services.AddOData(builder =>
{
    builder.RegisterTypes(
        typeof(ProductResponse),
        typeof(OrderResponse),
        typeof(CustomerResponse)
    );
});

// With custom options
services.AddOData(
    options =>
    {
        options.PageSize = 100;
        options.IgnoreExpand = false;
        options.IgnoreCount = false;
    },
    builder =>
    {
        builder.RegisterEntitiesFromAssemblies<IEntity>(typeof(MyEntity).Assembly);
    });

In Your Service/Handler

public class ProductService
{
    private readonly AppDbContext _dbContext;
    private readonly IODataService _oDataService;

    public ProductService(AppDbContext dbContext, IODataService oDataService)
    {
        _dbContext = dbContext;
        _oDataService = oDataService;
    }

    public async Task<List<Product>> GetProductsAsync()
    {
        return await _dbContext.Products
            .Where(p => !p.IsDeleted)
            .ApplyODataQuery(_oDataService)
            .ToListAsync();
    }
}

Selective Application

public async Task<List<Product>> GetProductsAsync()
{
    return await _dbContext.Products
        .ApplyODataFilter(_oDataService)      // only $filter from request
        .OrderByDescending(p => p.CreatedAt)  // custom ordering
        .Take(50)                             // custom limit
        .ToListAsync();
}

Available Extension Methods

query.ApplyODataQuery(oDataService);       // all OData options
query.ApplyODataFilter(oDataService);      // $filter
query.ApplyODataOrderBy(oDataService);     // $orderby
query.ApplyODataPagination(oDataService);  // $skip and $top
query.ApplyODataSelect(oDataService);      // $select
query.ApplyODataApply(oDataService);       // $apply

// Conditional application
query.ApplyODataFilter(oDataService, isEnabled: shouldFilter);

Configuration Options

Option Default Description
PageSize null Maximum page size for results. Null means no limit.
IgnoreExpand true When true, $expand query option is ignored.
IgnoreCount true When true, $count query option is ignored.
HandleNullPropagation False How null propagation is handled during query composition.

Query Processing Order

  1. $apply
  2. $filter
  3. $orderby
  4. $skip
  5. $top
  6. $select

License

This repository is licensed with the MIT license.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 94 1/10/2026

Initial release