Class DataContextBase
Base implementation of a IDataContext.
Inheritance
Implements
Inherited Members
Namespace: Kephas.Data
Assembly: Kephas.Data.dll
Syntax
public abstract class DataContextBase : Context, IDataContext, IContext, IExpando, IDynamicMetaObjectProvider, IIndexable, ILoggable, IIdentifiable, IDisposable, IInitializable
Constructors
| Improve this Doc View SourceDataContextBase(ICompositionContext, IDataCommandProvider, IDataBehaviorProvider, IDataContextCache)
Initializes a new instance of the DataContextBase class.
Declaration
protected DataContextBase(ICompositionContext compositionContext, IDataCommandProvider dataCommandProvider = null, IDataBehaviorProvider dataBehaviorProvider = null, IDataContextCache localCache = null)
Parameters
Type | Name | Description |
---|---|---|
ICompositionContext | compositionContext | The composition context. |
IDataCommandProvider | dataCommandProvider | Optional. The data command provider. If not provided, the DefaultDataCommandProvider will be used. |
IDataBehaviorProvider | dataBehaviorProvider | Optional. The data behavior provider. |
IDataContextCache | localCache | Optional. The local cache. If not provided, a new DataContextCache will be created. |
Fields
| Improve this Doc View SourceInitializationMonitor
The initialization monitor.
Declaration
protected readonly InitializationMonitor<DataContextBase> InitializationMonitor
Field Value
Type | Description |
---|---|
InitializationMonitor<DataContextBase> |
Properties
| Improve this Doc View SourceEntityActivator
Gets the entity activator.
Declaration
public virtual IActivator EntityActivator { get; }
Property Value
Type | Description |
---|---|
IActivator | The entity activator. |
Id
Gets the identifier for this instance.
Declaration
public object Id { get; }
Property Value
Type | Description |
---|---|
System.Object | The identifier. |
LocalCache
Gets the local cache where the session entities are stored.
Declaration
protected virtual IDataContextCache LocalCache { get; }
Property Value
Type | Description |
---|---|
IDataContextCache | The local cache. |
Methods
| Improve this Doc View SourceAttach(Object)
Attaches the entity to the data context.
Declaration
public virtual IEntityEntry Attach(object entity)
Parameters
Type | Name | Description |
---|---|---|
System.Object | entity | The entity. |
Returns
Type | Description |
---|---|
IEntityEntry | The entity entry information. |
AttachCore(Object, Boolean)
Attaches the entity to the data context, optionally attaching the whole entity graph.
Declaration
protected virtual IEntityEntry AttachCore(object entity, bool attachEntityGraph)
Parameters
Type | Name | Description |
---|---|---|
System.Object | entity | The entity. |
System.Boolean | attachEntityGraph |
|
Returns
Type | Description |
---|---|
IEntityEntry | The entity extended information. |
CreateCommand(Type)
Creates the command with the provided type.
Declaration
public IDataCommand CreateCommand(Type commandType)
Parameters
Type | Name | Description |
---|---|---|
System.Type | commandType | The type of the command to be created. |
Returns
Type | Description |
---|---|
IDataCommand | The new command. |
CreateEntityEntry(Object, Nullable<ChangeState>)
Creates a new entity entry.
Declaration
protected virtual IEntityEntry CreateEntityEntry(object entity, ChangeState? changeState = default(ChangeState? ))
Parameters
Type | Name | Description |
---|---|---|
System.Object | entity | The entity. |
System.Nullable<ChangeState> | changeState | The entity's change state. |
Returns
Type | Description |
---|---|
IEntityEntry | The new entity entry. |
Detach(IEntityEntry)
Detaches the entity from the data context.
Declaration
public virtual IEntityEntry Detach(IEntityEntry entityEntry)
Parameters
Type | Name | Description |
---|---|---|
IEntityEntry | entityEntry | The entity entry. |
Returns
Type | Description |
---|---|
IEntityEntry | The entity entry information. |
DetachCore(IEntityEntry, Boolean)
Detaches the entity from the data context.
Declaration
protected virtual IEntityEntry DetachCore(IEntityEntry entityEntry, bool detachEntityGraph)
Parameters
Type | Name | Description |
---|---|---|
IEntityEntry | entityEntry | The entity entry. |
System.Boolean | detachEntityGraph |
|
Returns
Type | Description |
---|---|
IEntityEntry | The entity extended information, or |
GetEntityEntry(Object)
Gets the entity extended information.
Declaration
public virtual IEntityEntry GetEntityEntry(object entity)
Parameters
Type | Name | Description |
---|---|---|
System.Object | entity | The entity. |
Returns
Type | Description |
---|---|
IEntityEntry | The entity extended information. |
Remarks
Note to inheritors: it is a good practice to override this method and provide a custom implementation, because, by default, the framework implementation returns each time a new EntityEntry.
GetIdEqualityExpression<T>(Object)
Gets the equality expression for of: t => t.Id == entityEntry.Id.
Declaration
protected virtual Expression<Func<T, bool>> GetIdEqualityExpression<T>(object entityId)
Parameters
Type | Name | Description |
---|---|---|
System.Object | entityId | The entity ID. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression<System.Func<T, System.Boolean>> | The equality expression. |
Type Parameters
Name | Description |
---|---|
T | The entity type. |
Initialize(IDataInitializationContext)
Initializes the service asynchronously.
Declaration
protected virtual void Initialize(IDataInitializationContext dataInitializationContext)
Parameters
Type | Name | Description |
---|---|---|
IDataInitializationContext | dataInitializationContext | The data initialization context. |
Initialize(IContext)
Initializes the service asynchronously.
Declaration
public void Initialize(IContext context)
Parameters
Type | Name | Description |
---|---|---|
IContext | context | The initialization context. |
Query<T>(IQueryOperationContext)
Gets a query over the entity type for the given query operation context, if any is provided.
Declaration
public virtual IQueryable<T> Query<T>(IQueryOperationContext queryOperationContext = null)
where T : class
Parameters
Type | Name | Description |
---|---|---|
IQueryOperationContext | queryOperationContext | 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. |
QueryCore<T>(IQueryOperationContext)
Gets a query over the entity type for the given query operation context, if any is provided (core implementation).
Declaration
protected abstract IQueryable<T> QueryCore<T>(IQueryOperationContext queryOperationContext)
where T : class
Parameters
Type | Name | Description |
---|---|---|
IQueryOperationContext | queryOperationContext | 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. |
ResolveAttachConflict(IEntityEntry, Object, Boolean)
Resolves the attach conflict between an existing attached entity and a challenger.
Declaration
protected virtual IEntityEntry ResolveAttachConflict(IEntityEntry entityEntry, object entityChallenger, bool attachEntityGraph)
Parameters
Type | Name | Description |
---|---|---|
IEntityEntry | entityEntry | The entity entry. |
System.Object | entityChallenger | The entity challenger. |
System.Boolean | attachEntityGraph |
|
Returns
Type | Description |
---|---|
IEntityEntry | An resolved IEntityEntry. |
Remarks
By default, the entity challenger is ignored. A derived class may decide to update the existing entity with refreshed information.