C# Class System.Data.Entity.Internal.LazyInternalContext

A LazyInternalContext is a concrete InternalContext type that will lazily create the underlying ObjectContext when needed. The ObjectContext created is owned by the internal context and will be disposed when the internal context is disposed.
Inheritance: InternalContext
Exibir arquivo Open project: aspnet/EntityFramework6 Class Usage Examples

Public Methods

Method Description
CreateModel ( LazyInternalContext internalContext ) : DbCompiledModel

Creates an immutable, cacheable representation of the model defined by this builder. This model can be used to create an ObjectContext or can be passed to a DbContext constructor to create a DbContext for this model.

CreateModelBuilder ( ) : DbModelBuilder

Creates and configures the DbModelBuilder instance that will be used to build the DbCompiledModel.

DisposeContext ( bool disposing ) : void

Disposes the context. The underlying ObjectContext is also disposed. The connection to the database (DbConnection object) is also disposed if it was created by the context, otherwise it is not disposed.

GetObjectContextWithoutDatabaseInitialization ( ) : ObjectContext

Returns the underlying ObjectContext without causing the underlying database to be created or the database initialization strategy to be executed. This is used to get a context that can then be used for database creation/initialization.

LazyInternalContext ( DbContext owner, IInternalConnection internalConnection, DbCompiledModel model, IDbModelCacheKey>.Func cacheKeyFactory = null, System.Data.Entity.ModelConfiguration.Utilities.AttributeProvider attributeProvider = null, Lazy dispatchers = null, ObjectContext objectContext = null ) : System.Collections.Concurrent

Constructs a LazyInternalContext for the given DbContext owner that will be initialized on first use.

MarkDatabaseInitialized ( ) : void

Marks the database as having been initialized without actually running the .

MarkDatabaseNotInitialized ( ) : void

Marks the database as having not been initialized. This is called when the app calls Database.Delete so that the database if the app attempts to then use the database again it will be re-initialized automatically.

OverrideConnection ( IInternalConnection connection ) : void
SaveChanges ( ) : int

Saves all changes made in this context to the underlying database, but only if the context has been initialized. If the context has not been initialized, then this method does nothing because there is nothing to do; in particular, it does not cause the context to be initialized.

SaveChangesAsync ( CancellationToken cancellationToken ) : Task

Protected Methods

Method Description
InitializeContext ( ) : void

Initializes the underlying ObjectContext.

InitializeDatabase ( ) : void

Runs the IDatabaseInitializer{TContext} unless it has already been run or there is no initializer for this context type in which case this method does nothing.

Private Methods

Method Description
InitializeDatabaseAction ( Action action ) : void

Performs some action (which may do nothing) in such a way that it is guaranteed only to be run once for the model and connection in this app domain, unless it fails by throwing an exception, in which case it will be re-tried next time the context is initialized.

StripInvalidCharacters ( string value ) : string

Method Details

CreateModel() public static method

Creates an immutable, cacheable representation of the model defined by this builder. This model can be used to create an ObjectContext or can be passed to a DbContext constructor to create a DbContext for this model.
public static CreateModel ( LazyInternalContext internalContext ) : DbCompiledModel
internalContext LazyInternalContext
return DbCompiledModel

CreateModelBuilder() public method

Creates and configures the DbModelBuilder instance that will be used to build the DbCompiledModel.
public CreateModelBuilder ( ) : DbModelBuilder
return DbModelBuilder

DisposeContext() public method

Disposes the context. The underlying ObjectContext is also disposed. The connection to the database (DbConnection object) is also disposed if it was created by the context, otherwise it is not disposed.
public DisposeContext ( bool disposing ) : void
disposing bool
return void

GetObjectContextWithoutDatabaseInitialization() public method

Returns the underlying ObjectContext without causing the underlying database to be created or the database initialization strategy to be executed. This is used to get a context that can then be used for database creation/initialization.
public GetObjectContextWithoutDatabaseInitialization ( ) : ObjectContext
return ObjectContext

InitializeContext() protected method

Initializes the underlying ObjectContext.
protected InitializeContext ( ) : void
return void

InitializeDatabase() protected method

Runs the IDatabaseInitializer{TContext} unless it has already been run or there is no initializer for this context type in which case this method does nothing.
protected InitializeDatabase ( ) : void
return void

LazyInternalContext() public method

Constructs a LazyInternalContext for the given DbContext owner that will be initialized on first use.
public LazyInternalContext ( DbContext owner, IInternalConnection internalConnection, DbCompiledModel model, IDbModelCacheKey>.Func cacheKeyFactory = null, System.Data.Entity.ModelConfiguration.Utilities.AttributeProvider attributeProvider = null, Lazy dispatchers = null, ObjectContext objectContext = null ) : System.Collections.Concurrent
owner DbContext // The owner . //
internalConnection IInternalConnection Responsible for creating a connection lazily when the context is used for the first time.
model DbCompiledModel The model, or null if it will be created by convention
cacheKeyFactory IDbModelCacheKey>.Func
attributeProvider System.Data.Entity.ModelConfiguration.Utilities.AttributeProvider
dispatchers Lazy
objectContext ObjectContext
return System.Collections.Concurrent

MarkDatabaseInitialized() public method

Marks the database as having been initialized without actually running the .
public MarkDatabaseInitialized ( ) : void
return void

MarkDatabaseNotInitialized() public method

Marks the database as having not been initialized. This is called when the app calls Database.Delete so that the database if the app attempts to then use the database again it will be re-initialized automatically.
public MarkDatabaseNotInitialized ( ) : void
return void

OverrideConnection() public method

public OverrideConnection ( IInternalConnection connection ) : void
connection IInternalConnection
return void

SaveChanges() public method

Saves all changes made in this context to the underlying database, but only if the context has been initialized. If the context has not been initialized, then this method does nothing because there is nothing to do; in particular, it does not cause the context to be initialized.
public SaveChanges ( ) : int
return int

SaveChangesAsync() public method

public SaveChangesAsync ( CancellationToken cancellationToken ) : Task
cancellationToken System.Threading.CancellationToken
return Task