C# Класс 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.
Наследование: InternalContext
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
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.

Приватные методы

Метод Описание
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

Описание методов

CreateModel() публичный статический Метод

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
Результат DbCompiledModel

CreateModelBuilder() публичный Метод

Creates and configures the DbModelBuilder instance that will be used to build the DbCompiledModel.
public CreateModelBuilder ( ) : DbModelBuilder
Результат DbModelBuilder

DisposeContext() публичный Метод

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
Результат void

GetObjectContextWithoutDatabaseInitialization() публичный Метод

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
Результат ObjectContext

InitializeContext() защищенный Метод

Initializes the underlying ObjectContext.
protected InitializeContext ( ) : void
Результат void

InitializeDatabase() защищенный Метод

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
Результат void

LazyInternalContext() публичный Метод

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
Результат System.Collections.Concurrent

MarkDatabaseInitialized() публичный Метод

Marks the database as having been initialized without actually running the .
public MarkDatabaseInitialized ( ) : void
Результат void

MarkDatabaseNotInitialized() публичный Метод

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
Результат void

OverrideConnection() публичный Метод

public OverrideConnection ( IInternalConnection connection ) : void
connection IInternalConnection
Результат void

SaveChanges() публичный Метод

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
Результат int

SaveChangesAsync() публичный Метод

public SaveChangesAsync ( CancellationToken cancellationToken ) : Task
cancellationToken System.Threading.CancellationToken
Результат Task