-
Notifications
You must be signed in to change notification settings - Fork 3
Base API Controller Classes
EDennis.AspNetCore.Base provides a WriteableController base class and a ReadonlyController base class. The WriteableController class is designed to be used with a WriteableRepo (non-temporal version) where the underlying entity has a simple integer ID. The ReadonlyController class is designed to be used with a ReadonlyRepo (non-temporal version), which utilizes a relational database. This page summarizes the endpoints available for each base controller.
WriteableController provides base CRUD endpoints, as well as Swagger-friendly endpoints for querying via OData expressions, Dynamic Linq expressions, and DevExtreme.AspNet.Data.DataSourceLoader.
WriteableController has two type parameters:
| Type Parameter | Constraints |
|---|---|
TEntity |
TEntity is a class with a default constructor and implements both IHasSysUser and IHasIntegerId |
TContext |
TContext extends Microsoft.EntityFrameworkCore.DbContext |
The WriteableController constructor accepts one argument:
- WriteableRepo<TEntity, TContext> -- any valid WriteableRepo subclass
public WriteableRepo(WriteableRepo<TEntity, TContext> repo)WriteableController exposes several endpoints.
| Endpoint | Action Parameters | Description |
|---|---|---|
| /odata | select, orderBy, filter, expand, skip (int?), top (int?) |
Query by OData |
| /devextreme |
select, sort, filter, skip (int?), take (int?), totalSummary, group, groupSummary |
Query by DevExtreme |
| /linq | select, orderBy, where, skip (int?), take (int?) |
Query by OData |
| /linq/async | (same as /linq) | Asynchronous version of /linq |
| /get/{id} | id (int) |
Query by integer primary key |
| /get/async/{id} | (same as /get/{id}) | Asynchronous version of /get/{id} |
| /post | (none) | Post a new object -- requires JSON body |
| /post/async | (none) | Asynchronous version of /post |
| /put/{id} | id (int) |
Modify by integer primary key -- requires JSON body |
| /put/async/{id} | (same as /put/{id}) | Asynchronous version of /put/{id} |
| /delete/{id} | id (int) |
Delete by integer primary key |
| /delete/async/{id} | (same as /delete/{id}) | Asynchronous version of /delete/{id} |
ReadonlyController provides Swagger-friendly endpoints for querying via OData expressions, Dynamic Linq expressions, and DevExtreme.AspNet.Data.DataSourceLoader, as well as Postman-friendly endpoints for calling parameterized stored procedures.
ReadonlyController has two type parameters:
| Type Parameter | Constraints |
|---|---|
TEntity |
TEntity is a class with a default constructor |
TContext |
TContext extends Microsoft.EntityFrameworkCore.DbContext |
The ReadonlyController constructor accepts one argument:
- ReadonlyRepo<TEntity, TContext> -- any valid ReadonlyRepo subclass
public ReadonlyRepo(ReadonlyRepo<TEntity, TContext> repo)ReadonlyController exposes several endpoints.
| Endpoint | Action Parameters | Description |
|---|---|---|
| /odata | select, orderBy, filter, expand, skip (int?), top (int?) |
Query by OData |
| /devextreme |
select, sort, filter, skip (int?), take (int?), totalSummary, group, groupSummary |
Query by DevExtreme |
| /linq | select, orderBy, where, skip (int?), take (int?) |
Query by OData |
| /linq/async | (same as /linq) | Asynchronous version of /linq |
| /sp | spName and any number of other parameters |
Query by stored procedure and return a List |
| /sp/async | (same as /sp/async) | Asynchronous version of /sp/async |
| /json | spName and any number of other parameters |
Query by stored procedure and return a JSON string* |
| /json/async | (same as /json/async) | Asynchronous version of /json/async |
*The stored procedure must be configured to return JSON as a single varchar column called "Json"
Development Support
- Temporal Entities
- Base Repository Classes
- Base API Controller Classes
- ApiClient and SecureApiClient
- Security Utilities
- IServiceCollection Extension Methods
- HttpClient Extension Methods
- ScopeProperties
- MigrationsExtensionsDbContextDesignTimeFactory
Testing Support
- API Launcher
- Testing Strategy and Infrastructure
- Xunit Support Classes
- Testing Security Utilities
Related Projects