Skip to main content

Querying

Overview

Core.Querying encapsulates querying of data via REST API and standardize implementation of your API service.

Install

  • ASOL.Core.Querying
  • ASOL.Core.Querying.AspNetCore

Usage third party libraries (NuGets)

Changelog

  • 0.0.1.24136-dev
    • .NET 8 support
  • 0.0.1.23685-dev
  • 0.0.1.14343-dev

Dependency injection

Mandatory dependency injection for Querying.

/// <summary>
/// OData support, see: https://www.odata.org/
/// </summary>
public static IServiceCollection AddODataSupport(this IServiceCollection services)
{
services.AddOData();
//fix: https://github.com/OData/WebApi/issues/2024
//see: https://github.com/KishorNaik/Sol_OData_Swagger_Support
services.AddMvcCore(options =>
{
foreach (var outputFormatter in options.OutputFormatters.OfType<OutputFormatter>().Where(x => x.SupportedMediaTypes.Count == 0))
{
outputFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/prs.odatatestxx-odata"));
}

foreach (var inputFormatter in options.InputFormatters.OfType<InputFormatter>().Where(x => x.SupportedMediaTypes.Count == 0))
{
inputFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/prs.odatatestxx-odata"));
}
});

return services;
}