Interface IAmorphousData
Denotes an entity, which is typically a row-derivative, that has extra data fields that are not defined by particular schema and get represented as {name:value} map instead (schema-less data). This interface is usually implemented by rows that support version changing between releases, i.e. when structured storage (such as Mongo DB) stores more fields than are currently declared in the row the extra fields will be placed in the AmorphousData collection. This interface also provides hook BeforeSave()/AfterLoad() that allow for transforms between Amorphous and "hard-schema" data models
Namespace: NFX.DataAccess.CRUD
Assembly: NFX.dll
Syntax
public interface IAmorphousData
Properties
AmorphousData
Returns data that does not comply with known schema (dynamic data). The field names are NOT case-sensitive
Declaration
IDictionary<string, object> AmorphousData { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, System.Object> |
AmorphousDataEnabled
When true, enabled amorphous data behaviour, i.e. copying of amorphous data between rows. When false, the amorphous data is ignored as-if the type did not implement this interface This is needed for security, i.e. on the web returning false will prevent injection via posted forms
Declaration
bool AmorphousDataEnabled { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
AfterLoad(String)
Invoked to allow the entity (such as a row) to hydrate its fields/state from AmorphousData bag. For example, this may be used to reconstruct some temporary object state that is not stored as a part of established business schema. The operation is performed per particular targetName (name of physical backend). Simply put, this method allows business code to "specify what to do after object gets loaded from THE PARTICULAR TARGET backend store". An example: suppose current MongoDB collection stores 3 fields for name, and we want to collapse First/Last/Middle name fields into one field. If we change rowschema then it will only contain 1 field which is not present in the database, however those 'older' fields will get populated into AmorphousData giving us an option to merge older 3 fields into 1 within AfterLoad() implementation
Declaration
void AfterLoad(string targetName)
Parameters
Type | Name | Description |
---|---|---|
System.String | targetName |
BeforeSave(String)
Invoked to allow the entity (such as a row) to transform its state into AmorphousData bag. For example, this may be usefull to store extra data that is not a part of established business schema. The operation is performed per particular targetName (name of physical backend). Simply put, this method allows business code to "specify what to do before object gets saved in THE PARTICULAR TARGET backend store"
Declaration
void BeforeSave(string targetName)
Parameters
Type | Name | Description |
---|---|---|
System.String | targetName |