Class AsyncEntitySetController<TEntity, TKey>
Provides a convenient starting point for a controller that exposes an OData entity set. This is the asynchronous version of EntitySetController<TEntity, TKey>.
[CLSCompliant(false)]
[ODataNullValue]
public abstract class AsyncEntitySetController<TEntity, TKey> : ODataController where TEntity : class
Type Parameters
TEntity
The type associated with the exposed entity set's entity type.
TKey
The type associated with the entity key of the exposed entity set's entity type.
- Inheritance
-
AsyncEntitySetController<TEntity, TKey>
- Inherited Members
Constructors
AsyncEntitySetController()
protected AsyncEntitySetController()
Properties
ODataPath
Gets the OData path of the current request.
public ODataPath ODataPath { get; }
Property Value
QueryOptions
Gets the OData query options of the current request.
public ODataQueryOptions<TEntity> QueryOptions { get; }
Property Value
- ODataQueryOptions<TEntity>
Methods
CreateEntityAsync(TEntity)
This method should be overridden to create a new entity in the entity set.
protected virtual Task<TEntity> CreateEntityAsync(TEntity entity)
Parameters
entity
TEntityThe entity to add to the entity set.
Returns
CreateLink(TKey, string, Uri)
This method should be overridden to handle POST and PUT requests that attempt to create a link between two entities.
public virtual Task CreateLink(TKey key, string navigationProperty, Uri link)
Parameters
key
TKeyThe key of the entity with the navigation property.
navigationProperty
stringThe name of the navigation property.
link
UriThe URI of the entity to link.
Returns
Delete(TKey)
This method should be overridden to handles DELETE requests for deleting existing entities from the entity set.
public virtual Task Delete(TKey key)
Parameters
key
TKeyThe entity key of the entity to delete.
Returns
DeleteLink(TKey, string, string)
This method should be overridden to handle DELETE requests that attempt to break a relationship between two entities.
public virtual Task DeleteLink(TKey key, string relatedKey, string navigationProperty)
Parameters
key
TKeyThe key of the entity with the navigation property.
relatedKey
stringThe key of the related entity.
navigationProperty
stringThe name of the navigation property.
Returns
DeleteLink(TKey, string, Uri)
This method should be overridden to handle DELETE requests that attempt to break a relationship between two entities.
public virtual Task DeleteLink(TKey key, string navigationProperty, Uri link)
Parameters
key
TKeyThe key of the entity with the navigation property.
navigationProperty
stringThe name of the navigation property.
link
UriThe URI of the entity to remove from the navigation property.
Returns
Get()
This method should be overridden to handle GET requests that attempt to retrieve entities from the entity set. This method should asynchronously compute the matching entities by applying the request's query options.
public virtual Task<IEnumerable<TEntity>> Get()
Returns
- Task<IEnumerable<TEntity>>
A Task that contains the matching entities from the entity set when it completes.
Get(TKey)
Handles GET requests that attempt to retrieve an individual entity by key from the entity set.
public virtual Task<HttpResponseMessage> Get(TKey key)
Parameters
key
TKeyThe entity key of the entity to retrieve.
Returns
- Task<HttpResponseMessage>
A Task that contains the response message to send back to the client when it completes.
GetEntityByKeyAsync(TKey)
This method should be overridden to retrieve an entity by key from the entity set.
protected virtual Task<TEntity> GetEntityByKeyAsync(TKey key)
Parameters
key
TKeyThe entity key of the entity to retrieve.
Returns
- Task<TEntity>
A Task that contains the retrieved entity when it completes, or null if an entity with the specified entity key cannot be found in the entity set.
GetKey(TEntity)
This method should be overridden to get the entity key of the specified entity.
protected virtual TKey GetKey(TEntity entity)
Parameters
entity
TEntityThe entity.
Returns
- TKey
The entity key value
HandleUnmappedRequest(ODataPath)
This method should be overridden to handle all unmapped OData requests.
public virtual Task<HttpResponseMessage> HandleUnmappedRequest(ODataPath odataPath)
Parameters
odataPath
ODataPathThe OData path of the request.
Returns
- Task<HttpResponseMessage>
A Task that contains the response message to send back to the client when it completes.
Patch(TKey, Delta<TEntity>)
Handles PATCH and MERGE requests to partially update a single entity in the entity set.
public virtual Task<HttpResponseMessage> Patch(TKey key, Delta<TEntity> patch)
Parameters
key
TKeyThe entity key of the entity to update.
patch
Delta<TEntity>The patch representing the partial update.
Returns
- Task<HttpResponseMessage>
A Task that contains the response message to send back to the client when it completes.
PatchEntityAsync(TKey, Delta<TEntity>)
This method should be overridden to apply a partial update to an existing entity in the entity set.
protected virtual Task<TEntity> PatchEntityAsync(TKey key, Delta<TEntity> patch)
Parameters
key
TKeyThe entity key of the entity to update.
patch
Delta<TEntity>The patch representing the partial update.
Returns
Post(TEntity)
Handles POST requests that create new entities in the entity set.
public virtual Task<HttpResponseMessage> Post(TEntity entity)
Parameters
entity
TEntityThe entity to insert into the entity set.
Returns
- Task<HttpResponseMessage>
A Task that contains the response message to send back to the client when it completes.
Put(TKey, TEntity)
Handles PUT requests that attempt to replace a single entity in the entity set.
public virtual Task<HttpResponseMessage> Put(TKey key, TEntity update)
Parameters
key
TKeyThe entity key of the entity to replace.
update
TEntityThe updated entity.
Returns
- Task<HttpResponseMessage>
A Task that contains the response message to send back to the client when it completes.
UpdateEntityAsync(TKey, TEntity)
This method should be overridden to update an existing entity in the entity set.
protected virtual Task<TEntity> UpdateEntityAsync(TKey key, TEntity update)
Parameters
key
TKeyThe entity key of the entity to update.
update
TEntityThe updated entity.