BlazorOdataClient 0.0.1.9

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package BlazorOdataClient --version 0.0.1.9
                    
NuGet\Install-Package BlazorOdataClient -Version 0.0.1.9
                    
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="BlazorOdataClient" Version="0.0.1.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BlazorOdataClient" Version="0.0.1.9" />
                    
Directory.Packages.props
<PackageReference Include="BlazorOdataClient" />
                    
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 BlazorOdataClient --version 0.0.1.9
                    
#r "nuget: BlazorOdataClient, 0.0.1.9"
                    
#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 BlazorOdataClient@0.0.1.9
                    
#: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=BlazorOdataClient&version=0.0.1.9
                    
Install as a Cake Addin
#tool nuget:?package=BlazorOdataClient&version=0.0.1.9
                    
Install as a Cake Tool

Blazor Odata Client

This client library provides virtualization to an ODATA endpoint. This library extends the existing <Virtualize> component built into .net 6.

Package Manager

Install-Package BlazorOdataClient -Version 0.0.1.9

Client Program.cs

using BlazorOdataClient;
builder.Services.AddOdataClient(httpClientName: "ConsumerApp.ServerAPI");

Usage:

@using BlazorOdataClient
<OdataVirtualize @ref="view"
                 TItem="WeatherForecast"
                 EndPoint="WeatherForecast"
                 QueryString="$OrderBy=Date desc"
                 OverscanCount="4">

    <tr>
        <td>@context.Date.LocalDateTime.ToShortDateString()</td>
        <td>@context.TemperatureC</td>
        <td>@context.TemperatureF</td>
        <td>@context.Summary</td>
    </tr>

</OdataVirtualize>

Parameters:

Parameter
TItem Specifies the type of item returned from the endpoint.
EndPoint Specifies the odata endpoint to be appended to the bases addess from the HttpClient. This will be prefixed with "odata/" This can be changed via an optional parameter on AddOdataClient()
QueryString Valid odata query.
OverscanCount This is directly passed the blazor <Virtualize> component. Virtualization

Endpoint used:

[Authorize]
[ApiController]
[Route(template: "api/[controller]")]
public class WeatherForecastController : ControllerBase
{
    private readonly ApplicationDbContext dbContext;
    public WeatherForecastController(ApplicationDbContext dbContext) => this.dbContext = dbContext;

    [HttpGet]
    [EnableQuery]
    public IQueryable<WeatherForecast> Get() => dbContext.WeatherForecasts;
}

Note: the use of the IQueryable. This allows the query to be passed directly to the database engine. The benefit of this is often overlooked. Database engines are designed to sort, filter, query data. dbContext.WeatherForecasts is of type DbSet<WeatherForecast> which implements IQueryable<>

Server Program.cs

builder.Services.AddControllers().AddOData(options => options
    .Select().Filter().OrderBy().SetMaxTop(maxTopValue: 100).SkipToken().Count()
    .AddRouteComponents(routePrefix: "odata", OdataConfig.GetEdmModel()));

For the component to work the Edm approach is required. The following configures the WeatherForecast odata endpoint to the WeatherForecast API.

public static class OdataConfig
{
    public static IEdmModel GetEdmModel()
    {
        var odataBuilder = new ODataConventionModelBuilder();
        odataBuilder.EntitySet<WeatherForecast>(name: "WeatherForecast");
        return odataBuilder.GetEdmModel();
    }
}

I have tested this with 100,000 records and the performance was impressive.

Migrations and Seeding the demonstration app.

To rebuild the scripts I perform the following steps.

  1. Delete the database (close existing connections).
  2. Delete the Migrations folder under \Data
  3. Re-create the migration scripts From the package manager console: (making sure ConsumerApp.Server is the default project)
Add-Migration CreateInitialSchema -OutputDir Data/Migrations
  1. Update the database
Update-Database

This statement

builder.Services.AddOdataClient(httpClientName: "ConsumerApp.ServerAPI");

adds the following services for injection

public interface IOdataClientFactory
{
    IOdataService<T> Create<T>(string endPoint);
    IOdataService<T> Create<T>(string httpClientName, string endPoint);
}

public interface IOdataService<TItem>
{
    ValueTask<OdataResponce<TItem>> GetOdataResponceAsync(string query);
    ValueTask<int> GetItemCountAsync(string queryString = "");
    ValueTask<ItemsProviderResult<TItem>> OdataPageAsync(ItemsProviderRequest request, string queryString);
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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. 
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

Note the change to an injectable service in the client for logging.