Class DataSpaceExtensions
Extension methods for IDataSpace.
Inheritance
Inherited Members
Namespace: Kephas.Data
Assembly: Kephas.Data.dll
Syntax
public static class DataSpaceExtensions
Methods
| Improve this Doc View SourceCreateAsync(IDataSpace, ICreateEntityContext, CancellationToken)
Creates asynchronously a new entity of the provided type and returns it.
Declaration
public static Task<object> CreateAsync(this IDataSpace dataSpace, ICreateEntityContext operationContext, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IDataSpace | dataSpace | The data space to act on. |
ICreateEntityContext | operationContext | Context for the create entity operation (optional). |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | A promise of the created entity. |
CreateAsync(IDataSpace, Type, CancellationToken)
Creates asynchronously a new entity of the provided type and returns it.
Declaration
public static Task<object> CreateAsync(this IDataSpace dataSpace, Type entityType, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IDataSpace | dataSpace | The data space to act on. |
System.Type | entityType | Type of the entity to create. |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | A promise of the created entity. |
CreateAsync<T>(IDataSpace, ICreateEntityContext, CancellationToken)
Creates asynchronously a new entity of the provided type and returns it.
Declaration
public static Task<T> CreateAsync<T>(this IDataSpace dataSpace, ICreateEntityContext operationContext, CancellationToken cancellationToken = default(CancellationToken))
where T : class
Parameters
Type | Name | Description |
---|---|---|
IDataSpace | dataSpace | The data space to act on. |
ICreateEntityContext | operationContext | Context for the create entity operation (optional). |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | A promise of the created entity. |
Type Parameters
Name | Description |
---|---|
T | The type of the entity to create. |
CreateAsync<T>(IDataSpace, CancellationToken)
Creates asynchronously a new entity of the provided type and returns it.
Declaration
public static Task<T> CreateAsync<T>(this IDataSpace dataSpace, CancellationToken cancellationToken = default(CancellationToken))
where T : class
Parameters
Type | Name | Description |
---|---|---|
IDataSpace | dataSpace | The data space to act on. |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | A promise of the created entity. |
Type Parameters
Name | Description |
---|---|
T | The type of the entity to create. |
Delete<T>(IDataSpace, T[])
Marks the provided entity for deletion in the data context.
Declaration
public static void Delete<T>(this IDataSpace dataSpace, params T[] entities)
where T : class
Parameters
Type | Name | Description |
---|---|---|
IDataSpace | dataSpace | The data space to act on. |
T[] | entities | The entities to delete. |
Type Parameters
Name | Description |
---|---|
T | The type of the entity. |
Delete<T>(IDataSpace, IEnumerable<T>)
Marks the provided entity for deletion in the data context.
Declaration
public static void Delete<T>(this IDataSpace dataSpace, IEnumerable<T> entities)
where T : class
Parameters
Type | Name | Description |
---|---|---|
IDataSpace | dataSpace | The data space to act on. |
System.Collections.Generic.IEnumerable<T> | entities | The entities to delete. |
Type Parameters
Name | Description |
---|---|
T | The type of the entity. |
DiscardChanges(IDataSpace)
Discards the changes in the data context.
Declaration
public static IEnumerable<IDataCommandResult> DiscardChanges(this IDataSpace dataSpace)
Parameters
Type | Name | Description |
---|---|---|
IDataSpace | dataSpace | The data space to act on. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IDataCommandResult> | The result of discarding the changes. |
FindAsync(IDataSpace, IFindContext, CancellationToken)
Searches for the entity with the provided ID and returns it asynchronously.
Declaration
public static Task<object> FindAsync(this IDataSpace dataSpace, IFindContext findContext, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IDataSpace | dataSpace | The data space to act on. |
IFindContext | findContext | Context for the find operation. |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | A promise of the found entity. |
FindAsync(IDataSpace, Type, Object, Boolean, CancellationToken)
Searches for the entity with the provided ID and returns it asynchronously.
Declaration
public static Task<object> FindAsync(this IDataSpace dataSpace, Type entityType, object id, bool throwIfNotFound = true, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IDataSpace | dataSpace | The data space to act on. |
System.Type | entityType | Type of the entity. |
System.Object | id | The entity ID. |
System.Boolean | throwIfNotFound | If |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | A promise of the found entity. |
FindAsync<T>(IDataSpace, IFindContext, CancellationToken)
Searches for the entity with the provided ID and returns it asynchronously.
Declaration
public static Task<T> FindAsync<T>(this IDataSpace dataSpace, IFindContext findContext, CancellationToken cancellationToken = default(CancellationToken))
where T : class
Parameters
Type | Name | Description |
---|---|---|
IDataSpace | dataSpace | The data space to act on. |
IFindContext | findContext | Context for the find operation. |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | A promise of the found entity. |
Type Parameters
Name | Description |
---|---|
T | The type of the entity. |
FindAsync<T>(IDataSpace, Object, Boolean, CancellationToken)
Searches for the entity with the provided ID and returns it asynchronously.
Declaration
public static Task<T> FindAsync<T>(this IDataSpace dataSpace, object id, bool throwIfNotFound = true, CancellationToken cancellationToken = default(CancellationToken))
where T : class
Parameters
Type | Name | Description |
---|---|---|
IDataSpace | dataSpace | The data space to act on. |
System.Object | id | The entity ID. |
System.Boolean | throwIfNotFound | If |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | A promise of the found entity. |
Type Parameters
Name | Description |
---|---|
T | The type of the entity. |
FindOneAsync(IDataSpace, IFindOneContext, CancellationToken)
Searches for the first entity matching the provided criteria and returns it asynchronously.
Declaration
public static Task<object> FindOneAsync(this IDataSpace dataSpace, IFindOneContext findContext, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IDataSpace | dataSpace | The data space to act on. |
IFindOneContext | findContext | The find context. |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | A promise of the found entity. |
FindOneAsync<T>(IDataSpace, IFindOneContext, CancellationToken)
Searches for the first entity matching the provided criteria and returns it asynchronously.
Declaration
public static Task<T> FindOneAsync<T>(this IDataSpace dataSpace, IFindOneContext findContext, CancellationToken cancellationToken = default(CancellationToken))
where T : class
Parameters
Type | Name | Description |
---|---|---|
IDataSpace | dataSpace | The data space to act on. |
IFindOneContext | findContext | The find context. |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | A promise of the found entity. |
Type Parameters
Name | Description |
---|---|
T | The type of the entity. |
FindOneAsync<T>(IDataSpace, Expression<Func<T, Boolean>>, Boolean, CancellationToken)
Searches for the first entity matching the provided criteria and returns it asynchronously.
Declaration
public static Task<T> FindOneAsync<T>(this IDataSpace dataSpace, Expression<Func<T, bool>> criteria, bool throwIfNotFound = true, CancellationToken cancellationToken = default(CancellationToken))
where T : class
Parameters
Type | Name | Description |
---|---|---|
IDataSpace | dataSpace | The data space to act on. |
System.Linq.Expressions.Expression<System.Func<T, System.Boolean>> | criteria | The criteria. |
System.Boolean | throwIfNotFound |
|
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | A promise of the found entity. |
Type Parameters
Name | Description |
---|---|
T | The type of the entity. |
GetEntityEntry<T>(IDataSpace, T)
An IDataSpace extension method that gets The entity entry.
Declaration
public static IEntityEntry GetEntityEntry<T>(this IDataSpace dataSpace, T entity)
Parameters
Type | Name | Description |
---|---|---|
IDataSpace | dataSpace | The dataSpace to act on. |
T | entity | The entity. |
Returns
Type | Description |
---|---|
IEntityEntry | The entity entry. |
Type Parameters
Name | Description |
---|---|
T | Generic type parameter. |
PersistChangesAsync(IDataSpace, CancellationToken)
Persists the changes in the dataContext asynchronously.
Declaration
public static Task<IEnumerable<IDataCommandResult>> PersistChangesAsync(this IDataSpace dataSpace, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IDataSpace | dataSpace | The data space to act on. |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<IDataCommandResult>> | A promise of the persist result. |
Query<T>(IDataSpace, IQueryOperationContext)
Gets a query over the entity type for the given query operation context, if any is provided.
Declaration
public static IQueryable<T> Query<T>(this IDataSpace dataSpace, IQueryOperationContext operationContext = null)
where T : class
Parameters
Type | Name | Description |
---|---|---|
IDataSpace | dataSpace | The data space to act on. |
IQueryOperationContext | operationContext | Context for the query. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable<T> | A query over the entity type. |
Type Parameters
Name | Description |
---|---|
T | The entity type. |