Skip to content

AspNetCore

MisterHoker edited this page Apr 6, 2021 · 5 revisions

AspNetCore Source

General Information

AspNetCore source allow to get IQuery interface as action method parameter.
Currently, only binding from QueryString is supported.
It is strongly recommended to read about Extensibility in General

Model Binding

Class QueryNinjaModelBinder is responsible for model binding.
It tries to apply each query parameter to any of the IQueryComponentFactory.

Built-in support contains everything needed to work with QueryNinja.Core:

  • IDefaultFilter - parameter should look like filter.{property}.{operation}={value}. E.g.: filter.Name.Equals=Alex;
  • OrderingRule - parameter should look like order.{property}={direction}. E.g.: order.Name=Ascending
  • Selector - select={property} will select property and preserve the path to it and select.{source}={target} will take a source property and put it under target path.

Extensibility

If you will feel that you lack some IQueryComponents here you can easily extend existing behavior by registering own IQueryComponentFactory in QueryNinjaExtensions.

IQueryComponentFactory

IQueryComponentFactory allows to create IQueryComponent instance from QueryParameter.
For each user-defined IQueryComponents you must have instance of this factory that CanApply true.
However, process could be simplified if your component is IDIefaultFilter.

DefaultFilterFactory

DefaultFilterFactory allows to create instances of IDefaultFilter based on default filter patter described above.
It is two independent ways to enable user-defined IDefaultFilters for this factory:

  1. Register your filter in known components via QueryNinjaExtensions. ⚠️ Your filter must have parameterless constructure with parameters in order: operation, property, value.
  2. Configure factory with IAspNetCoreExtensionSettings

IAspNetCoreExtensionSettings

IAspNetCoreExtensionSettings allows to configure DefaultFilterFactory with your own IDefaultFilter.