-
Notifications
You must be signed in to change notification settings - Fork 14
Adapters
Adapters are a oData controller dispatching mechanism that allows users to specify complex query strings with filters and field selections. Unlike normal oData controllers, adapters don't make use of the EF Core provider, Adapters are backed by your custom code. Adapters transform the conditions specified in the oData query into a data structure that is similar to one that might be currently used when implementing search operations within your synergy applications. Adapters currently have support for filters based on equality, range, in set, and parameters.
Adapters are the preferred mechanism for exposing custom synergy code where the user may want to supply filter criteria, that needs to be applied at the database level. A good example would be if you have custom code that would be performance prohibitive to perform filtering actions after your code runs. oData is perfectly capable of applying transformations to the results of your custom code, but adapters allow you to filter down the results before they are handed back to oData.
Adapters are defined the same way you would for sproc routing with on difference. Methods that you intend to have dispatched this way should have a single parameter with AdapterParameterAttribute
applied. The type of the parameter should be a class comprised of public read/write properties, each with one of the Adapter attributes applied informing the system how to synthesize its value. Here is the list of supported Adapter attributes.
- ParameterFieldAdapterAttribute - named parameter passed inside the parentheses inside the uri, may be optional
- MatchFieldAdapterAttribute - inside the $filter clause, this can transform operations like field1 eq 'somevalue'
- RangeFieldAdapterAttribute - inside the $filter clause, this can transform operations that specify an upper, lower or both bounds for a value using the 'gt', 'lt', 'gte', 'lte' operators
- OrFieldAdapterAttribute - inside the $filter clause, this can transform operations where there are a set of 'or equals' operations.
in addition to the above changes that are made per method you want to expose, you will also need to enable the AdapterRoutingConvention
using something like the following inside your Startup.dbl, Configure method.
lambda EnableRouting(sp)
begin
;;Enable optional OData features
;;Enable $select expressions to select properties returned
builder.Select()
;;Enable $filter expressions to filter rows returned
builder.Filter()
;;Enable $orderby expressions to custom sort results
builder.OrderBy()
;;Enable /$count endpoints
builder.Count()
;;Enable $expand expressions to expand relations
builder.Expand()
;;Specify the maximum rows that may be returned by $top expressions
builder.MaxTop(100)
data routeList = ODataRoutingConventions.CreateDefaultWithAttributeRouting("uri_base_name", builder)
routeList.Insert(0, new AdapterRoutingConvention())
mreturn routeList
end
lambda ConfigureRoute(containerBuilder)
begin
...
containerBuilder.AddService<IEnumerable<IODataRoutingConvention>>(Microsoft.OData.ServiceLifetime.Singleton, EnableRouting)
end
builder.MapODataServiceRoute("uri_base_name", "uri_base_name", ConfigureRoute)
Alternatively if you're using the project templates we provide along with the regen.bat, you can just un-comment the following line
set ENABLE_ADAPTER_ROUTING=-define ENABLE_ADAPTER_ROUTING
-
Tutorial 2: Building a Service from Scratch
- Creating a Basic Solution
- Enabling OData Support
- Configuring Self Hosting
- Entity Collection Endpoints
- API Documentation
- Single Entity Endpoints
- OData Query Support
- Alternate Key Endpoints
- Expanding Relations
- Postman Tests
- Supporting CRUD Operations
- Adding a Primary Key Factory
- Adding Create Endpoints
- Adding Upsert Endpoints
- Adding Patch Endpoints
- Adding Delete Endpoints
-
Harmony Core Code Generator
-
OData Aware Tools
-
Advanced Topics
- CLI Tool Customization
- Adapters
- API Versioning
- Authentication
- Authorization
- Collection Counts
- Customization File
- Custom Field Types
- Custom File Specs
- Custom Properties
- Customizing Generated Code
- Deploying to Linux
- Dynamic Call Protocol
- Environment Variables
- Field Security
- File I/O
- Improving AppSettings Processing
- Logging
- Optimistic Concurrency
- Multi-Tenancy
- Publishing in IIS
- Repeatable Unit Tests
- Stored Procedure Routing
- Suppressing OData Metadata
- Traditional Bridge
- Unit Testing
- EF Core Optimization
- Updating a Harmony Core Solution
- Updating to 3.1.90
- Creating a new Release
-
Background Information