Show / Hide Table of Contents

Class DataContextBase

Base implementation of a IDataContext.

Inheritance
System.Object
System.Dynamic.DynamicObject
ExpandoBase
Expando
Context
DataContextBase
InMemoryDataContext
LLBLGenDataContext
MongoDataContext
Implements
IDataContext
IContext
IExpando
System.Dynamic.IDynamicMetaObjectProvider
IIndexable
ILoggable
IIdentifiable
System.IDisposable
IInitializable
Inherited Members
Context.AmbientServices
Context.CompositionContext
Context.Identity
Context.Logger
Context.Dispose()
Context.ValidateIdentity(IIdentity, IIdentity)
Context.SetCompositionContext(ICompositionContext)
Context.SetAmbientServices(IAmbientServices)
Context.Dispose(Boolean)
ExpandoBase.Item[String]
ExpandoBase.GetDynamicMemberNames()
ExpandoBase.HasDynamicMember(String)
ExpandoBase.TryGetMember(GetMemberBinder, Object)
ExpandoBase.TrySetMember(SetMemberBinder, Object)
ExpandoBase.TryInvokeMember(InvokeMemberBinder, Object[], Object)
ExpandoBase.ToDictionary(Func<String, String>, Func<Object, Object>)
ExpandoBase.GetInnerObjectTypeInfo()
ExpandoBase.GetThisTypeInfo()
ExpandoBase.TryGetValue(String, Object)
ExpandoBase.TrySetValue(String, Object)
System.Dynamic.DynamicObject.GetMetaObject(System.Linq.Expressions.Expression)
System.Dynamic.DynamicObject.TryBinaryOperation(System.Dynamic.BinaryOperationBinder, System.Object, System.Object)
System.Dynamic.DynamicObject.TryConvert(System.Dynamic.ConvertBinder, System.Object)
System.Dynamic.DynamicObject.TryCreateInstance(System.Dynamic.CreateInstanceBinder, System.Object[], System.Object)
System.Dynamic.DynamicObject.TryDeleteIndex(System.Dynamic.DeleteIndexBinder, System.Object[])
System.Dynamic.DynamicObject.TryDeleteMember(System.Dynamic.DeleteMemberBinder)
System.Dynamic.DynamicObject.TryGetIndex(System.Dynamic.GetIndexBinder, System.Object[], System.Object)
System.Dynamic.DynamicObject.TryInvoke(System.Dynamic.InvokeBinder, System.Object[], System.Object)
System.Dynamic.DynamicObject.TrySetIndex(System.Dynamic.SetIndexBinder, System.Object[], System.Object)
System.Dynamic.DynamicObject.TryUnaryOperation(System.Dynamic.UnaryOperationBinder, System.Object)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
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 Source

DataContextBase(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 Source

InitializationMonitor

The initialization monitor.

Declaration
protected readonly InitializationMonitor<DataContextBase> InitializationMonitor
Field Value
Type Description
InitializationMonitor<DataContextBase>

Properties

| Improve this Doc View Source

EntityActivator

Gets the entity activator.

Declaration
public virtual IActivator EntityActivator { get; }
Property Value
Type Description
IActivator

The entity activator.

| Improve this Doc View Source

Id

Gets the identifier for this instance.

Declaration
public object Id { get; }
Property Value
Type Description
System.Object

The identifier.

| Improve this Doc View Source

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 Source

Attach(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.

| Improve this Doc View Source

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

true to attach the whole entity graph.

Returns
Type Description
IEntityEntry

The entity extended information.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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

true to detach the whole entity graph.

Returns
Type Description
IEntityEntry

The entity extended information, or null if the entity is not attached to this data context.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

Initialize(IDataInitializationContext)

Initializes the service asynchronously.

Declaration
protected virtual void Initialize(IDataInitializationContext dataInitializationContext)
Parameters
Type Name Description
IDataInitializationContext dataInitializationContext

The data initialization context.

| Improve this Doc View Source

Initialize(IContext)

Initializes the service asynchronously.

Declaration
public void Initialize(IContext context)
Parameters
Type Name Description
IContext context

The initialization context.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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

true to attach the whole entity graph.

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.

Implements

IDataContext
IContext
IExpando
System.Dynamic.IDynamicMetaObjectProvider
IIndexable
ILoggable
IIdentifiable
System.IDisposable
IInitializable

Extension Methods

DynamicObjectExtensions.SetPropertyValue(Object, String, Object)
DynamicObjectExtensions.TrySetPropertyValue(Object, String, Object)
DynamicObjectExtensions.GetPropertyValue(Object, String)
DynamicObjectExtensions.TryGetPropertyValue(Object, String, out Object)
DynamicObjectExtensions.GetRuntimeTypeInfo(Object)
DynamicObjectExtensions.ToDynamic(Object)
DynamicObjectExtensions.ToExpando(Object)
BehaviorValue.ToBehaviorValue<TValue>(TValue)
CollectionExtensions.AddRange<T, TItem>(T, IEnumerable<TItem>)
LoggingExtensions.GetLogger(Object, IContext)
TypeExtensions.GetAbstractType(Object)
TypeExtensions.GetAbstractTypeInfo(Object)
ReflectionHelper.GetTypeInfo(Object)
MessageBrokerExtensions.CreateBrokeredMessageBuilder(IContext)
ContextExtensions.InitialData(IContext)
ContextExtensions.WithInitialData<TContext>(TContext, IEnumerable<(Object entity, ChangeState changeState)>)
ContextExtensions.WithInitialData<TContext>(TContext, IEnumerable<Object>)
ContextExtensions.WithInitialData<TContext>(TContext, IEnumerable<IChangeStateTrackableEntityEntry>)
DataContextExtensions.Detach(IDataContext, Object)
DataContextExtensions.CreateCommand<TCommand>(IDataContext)
DataContextExtensions.CreateAsync(IDataContext, Type, CancellationToken)
DataContextExtensions.CreateAsync(IDataContext, ICreateEntityContext, CancellationToken)
DataContextExtensions.CreateAsync<T>(IDataContext, CancellationToken)
DataContextExtensions.CreateAsync<T>(IDataContext, ICreateEntityContext, CancellationToken)
DataContextExtensions.FindAsync(IDataContext, Type, Object, Boolean, CancellationToken)
DataContextExtensions.FindAsync(IDataContext, IFindContext, CancellationToken)
DataContextExtensions.FindAsync<T>(IDataContext, IFindContext, CancellationToken)
DataContextExtensions.FindAsync<T>(IDataContext, Object, Boolean, CancellationToken)
DataContextExtensions.FindOneAsync(IDataContext, IFindOneContext, CancellationToken)
DataContextExtensions.FindOneAsync<T>(IDataContext, IFindOneContext, CancellationToken)
DataContextExtensions.FindOneAsync<T>(IDataContext, Expression<Func<T, Boolean>>, Boolean, CancellationToken)
DataContextExtensions.PersistChangesAsync(IDataContext, IPersistChangesContext, CancellationToken)
DataContextExtensions.DiscardChanges(IDataContext)
DataContextExtensions.Delete<T>(IDataContext, T[])
DataContextExtensions.Delete<T>(IDataContext, IEnumerable<T>)
DataContextExtensions.BulkDeleteAsync(IDataContext, IBulkDeleteContext, CancellationToken)
DataContextExtensions.BulkDeleteAsync<T>(IDataContext, Expression<Func<T, Boolean>>, Boolean, CancellationToken)
DataContextExtensions.BulkUpdateAsync<T>(IDataContext, Expression<Func<T, Boolean>>, Object, Boolean, CancellationToken)
DataContextExtensions.BulkUpdateAsync(IDataContext, IBulkUpdateContext, CancellationToken)
DataContextExtensions.ExecuteAsync(IDataContext, String, CancellationToken)
DataContextExtensions.ExecuteAsync(IDataContext, IExecuteContext, CancellationToken)
EntityEntryExtensions.TryGetAttachedEntityEntry(Object)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX