C# Class Breeze.ContextProvider.ContextProvider

显示文件 Open project: Breeze/breeze.server.net Class Usage Examples

Protected Properties

Property Type Description
KeyGeneratorType Lazy

Public Methods

Method Description
CreateEntityInfo ( Object entity, System.Data.EntityState entityState = EntityState.Added ) : EntityInfo
ExtractSaveOptions ( dynamic dynSaveBundle ) : SaveOptions
GetDbConnection ( ) : IDbConnection

Should only be called from BeforeSaveEntities and AfterSaveEntities.

GetKeyValues ( EntityInfo entityInfo ) : object[]
Metadata ( ) : string
SaveChanges ( Newtonsoft.Json.Linq.JObject saveBundle, Breeze.ContextProvider.TransactionSettings transactionSettings = null ) : SaveResult
XDocToJson ( System.Xml.Linq.XDocument xDoc ) : String

Protected Methods

Method Description
AfterSaveEntities ( Dictionary saveMap, List keyMappings ) : void

Called after the entities have been saved, and all the temporary keys have been replaced by real keys. The base implementation calls AfterSaveEntitiesDelegate, or does nothing if AfterSaveEntitiesDelegate is null.

BeforeSaveEntities ( Dictionary saveMap ) : List>.Dictionary

Called after BeforeSaveEntity, and before saving the entities to the persistence layer. Allows adding, changing, and removing entities prior to save. The base implementation returns the result of BeforeSaveEntitiesDelegate, or the unchanged saveMap if BeforeSaveEntitiesDelegate is null.

BeforeSaveEntity ( EntityInfo entityInfo ) : bool

The method is called for each entity to be saved before the save occurs. If this method returns 'false' then the entity will be excluded from the save. The base implementation returns the result of BeforeSaveEntityDelegate, or 'true' if BeforeSaveEntityDelegate is null.

BeginTransaction ( System isolationLevel ) : IDbTransaction
BuildJsonMetadata ( ) : String
CloseDbConnection ( ) : void

Internal use only. Should only be called by ContextProvider during SaveChanges. Closes the DbConnection used by the ContextProvider's implementation.

CreateEntityInfo ( ) : EntityInfo
CreateEntityInfoFromJson ( dynamic jo, Type entityType ) : EntityInfo
HandleSaveException ( Exception e, SaveWorkState saveWorkState ) : bool
InitializeSaveState ( Newtonsoft.Json.Linq.JObject saveBundle ) : void
LookupEntityType ( String entityTypeName ) : Type
OpenDbConnection ( ) : void

Internal use only. Should only be called by ContextProvider during SaveChanges. Opens the DbConnection used by the ContextProvider's implementation. Method must be idempotent; after it is called the first time, subsequent calls have no effect.

SaveChangesCore ( SaveWorkState saveWorkState ) : void

Private Methods

Method Description
CreateJsonSerializer ( ) : JsonSerializer
JsonToDictionary ( dynamic json ) : Object>.Dictionary
OpenAndSave ( SaveWorkState saveWorkState ) : void

Method Details

AfterSaveEntities() protected method

Called after the entities have been saved, and all the temporary keys have been replaced by real keys. The base implementation calls AfterSaveEntitiesDelegate, or does nothing if AfterSaveEntitiesDelegate is null.
protected AfterSaveEntities ( Dictionary saveMap, List keyMappings ) : void
saveMap Dictionary The same saveMap that was returned from BeforeSaveEntities
keyMappings List The mapping of temporary keys to real keys
return void

BeforeSaveEntities() protected method

Called after BeforeSaveEntity, and before saving the entities to the persistence layer. Allows adding, changing, and removing entities prior to save. The base implementation returns the result of BeforeSaveEntitiesDelegate, or the unchanged saveMap if BeforeSaveEntitiesDelegate is null.
protected BeforeSaveEntities ( Dictionary saveMap ) : List>.Dictionary
saveMap Dictionary A List of EntityInfo for each Type
return List>.Dictionary

BeforeSaveEntity() protected method

The method is called for each entity to be saved before the save occurs. If this method returns 'false' then the entity will be excluded from the save. The base implementation returns the result of BeforeSaveEntityDelegate, or 'true' if BeforeSaveEntityDelegate is null.
protected BeforeSaveEntity ( EntityInfo entityInfo ) : bool
entityInfo EntityInfo
return bool

BeginTransaction() protected method

protected BeginTransaction ( System isolationLevel ) : IDbTransaction
isolationLevel System
return IDbTransaction

BuildJsonMetadata() protected abstract method

protected abstract BuildJsonMetadata ( ) : String
return String

CloseDbConnection() protected abstract method

Internal use only. Should only be called by ContextProvider during SaveChanges. Closes the DbConnection used by the ContextProvider's implementation.
protected abstract CloseDbConnection ( ) : void
return void

CreateEntityInfo() protected method

protected CreateEntityInfo ( ) : EntityInfo
return EntityInfo

CreateEntityInfo() public method

public CreateEntityInfo ( Object entity, System.Data.EntityState entityState = EntityState.Added ) : EntityInfo
entity Object
entityState System.Data.EntityState
return EntityInfo

CreateEntityInfoFromJson() protected method

protected CreateEntityInfoFromJson ( dynamic jo, Type entityType ) : EntityInfo
jo dynamic
entityType System.Type
return EntityInfo

ExtractSaveOptions() public static method

public static ExtractSaveOptions ( dynamic dynSaveBundle ) : SaveOptions
dynSaveBundle dynamic
return SaveOptions

GetDbConnection() public abstract method

Should only be called from BeforeSaveEntities and AfterSaveEntities.
public abstract GetDbConnection ( ) : IDbConnection
return IDbConnection

GetKeyValues() public method

public GetKeyValues ( EntityInfo entityInfo ) : object[]
entityInfo EntityInfo
return object[]

HandleSaveException() protected method

protected HandleSaveException ( Exception e, SaveWorkState saveWorkState ) : bool
e System.Exception
saveWorkState SaveWorkState
return bool

InitializeSaveState() protected method

protected InitializeSaveState ( Newtonsoft.Json.Linq.JObject saveBundle ) : void
saveBundle Newtonsoft.Json.Linq.JObject
return void

LookupEntityType() protected method

protected LookupEntityType ( String entityTypeName ) : Type
entityTypeName String
return System.Type

Metadata() public method

public Metadata ( ) : string
return string

OpenDbConnection() protected abstract method

Internal use only. Should only be called by ContextProvider during SaveChanges. Opens the DbConnection used by the ContextProvider's implementation. Method must be idempotent; after it is called the first time, subsequent calls have no effect.
protected abstract OpenDbConnection ( ) : void
return void

SaveChanges() public method

public SaveChanges ( Newtonsoft.Json.Linq.JObject saveBundle, Breeze.ContextProvider.TransactionSettings transactionSettings = null ) : SaveResult
saveBundle Newtonsoft.Json.Linq.JObject
transactionSettings Breeze.ContextProvider.TransactionSettings
return SaveResult

SaveChangesCore() protected abstract method

protected abstract SaveChangesCore ( SaveWorkState saveWorkState ) : void
saveWorkState SaveWorkState
return void

XDocToJson() public static method

public static XDocToJson ( System.Xml.Linq.XDocument xDoc ) : String
xDoc System.Xml.Linq.XDocument
return String

Property Details

KeyGeneratorType protected_oe static_oe property

protected static Lazy KeyGeneratorType
return Lazy