Class EFPersistenceManager<T>
- Namespace
- Breeze.Persistence.EFCore
- Assembly
- Breeze.Persistence.EFCore.dll
Manages persistence for Breeze entity models using Entity Framework
public class EFPersistenceManager<T> : PersistenceManager, IEFContextProvider where T : DbContext
Type Parameters
T
- Inheritance
-
EFPersistenceManager<T>
- Implements
- Inherited Members
Constructors
EFPersistenceManager()
Create a manager with no context.
public EFPersistenceManager()
Remarks
Every member that needs a context throws until one is supplied; use EFPersistenceManager(T) unless you have a reason not to.
EFPersistenceManager(T)
Create a manager over a DbContext.
public EFPersistenceManager(T context)
Parameters
contextTThe context to save through and read metadata from.
Remarks
Cascade deletes and orphan deletes are deferred to save time, so that Breeze decides the order in which entities are saved.
Properties
Context
The context, as its own type.
public T Context { get; }
Property Value
- T
DbContext
The context, as a DbContext.
public DbContext DbContext { get; }
Property Value
EntityConnection
Gets the EntityConnection from the ObjectContext.
public DbConnection EntityConnection { get; }
Property Value
EntityTransaction
Gets the current transaction, if one is in progress.
public IDbContextTransaction? EntityTransaction { get; }
Property Value
Methods
BeginTransaction(IsolationLevel)
protected override IDbTransaction BeginTransaction(IsolationLevel isolationLevel)
Parameters
isolationLevelIsolationLevel
Returns
BeginTransactionAsync(IsolationLevel, CancellationToken)
Override BeginTransactionAsync and keep the transaction in the Entitytransaction property
protected override Task<IDbTransaction> BeginTransactionAsync(IsolationLevel isolationLevel, CancellationToken cancellationToken)
Parameters
isolationLevelIsolationLevelcancellationTokenCancellationToken
Returns
BuildAltJsonMetadata()
Allow a subclass to provide alternate metadata; null (the default) for none
protected virtual string? BuildAltJsonMetadata()
Returns
BuildJsonMetadata()
Build the Breeze metadata JSON from the EF model, including anything BuildAltJsonMetadata supplies.
protected override string BuildJsonMetadata()
Returns
- string
The metadata as JSON, camel-cased, with enums written as strings.
CloseDbConnection()
Close the db connection used by the DbContext.
protected override void CloseDbConnection()
CloseDbConnectionAsync()
Close the db connection used by the DbContext.
protected override Task CloseDbConnectionAsync()
Returns
CreateEntityInfo()
Create a new EFEntityInfo
protected override EntityInfo CreateEntityInfo()
Returns
GetDbConnection()
Gets the EntityConnection from the ObjectContext.
public override IDbConnection GetDbConnection()
Returns
GetEntitySetName(Type)
The name EF knows an entity type by.
public string GetEntitySetName(Type entityType)
Parameters
entityTypeTypeA mapped entity type.
Returns
- string
Its name in the EF model.
GetKeyValues(EntityInfo)
Get the primary key values from the Entity
public override object[] GetKeyValues(EntityInfo entityInfo)
Parameters
entityInfoEntityInfo
Returns
- object[]
GetKeyValues(object)
Get the primary key values from the Entity
public object[] GetKeyValues(object entity)
Parameters
entityobject
Returns
- object[]
OpenDbConnection()
Opens the DbConnection used by the Context. If the connection will be used outside of the DbContext, this method should be called prior to DbContext initialization, so that the connection will already be open when the DbContext uses it. This keeps the DbContext from closing the connection, so it must be closed manually. See http://blogs.msdn.com/b/diego/archive/2012/01/26/exception-from-dbcontext-api-entityconnection-can-only-be-constructed-with-a-closed-dbconnection.aspx
protected override void OpenDbConnection()
OpenDbConnectionAsync(CancellationToken)
Opens the DbConnection used by the Context. If the connection will be used outside of the DbContext, this method should be called prior to DbContext initialization, so that the connection will already be open when the DbContext uses it. This keeps the DbContext from closing the connection, so it must be closed manually. See http://blogs.msdn.com/b/diego/archive/2012/01/26/exception-from-dbcontext-api-entityconnection-can-only-be-constructed-with-a-closed-dbconnection.aspx
protected override Task OpenDbConnectionAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
SaveChangesCore(SaveWorkState)
Save changes and update key mappings
protected override void SaveChangesCore(SaveWorkState saveWorkState)
Parameters
saveWorkStateSaveWorkState
SaveChangesCoreAsync(SaveWorkState, CancellationToken)
Save changes and update key mappings
protected override Task SaveChangesCoreAsync(SaveWorkState saveWorkState, CancellationToken cancellationToken)
Parameters
saveWorkStateSaveWorkStatecancellationTokenCancellationToken