Table of contents
- 1 Example
- 2 Constructors
- 3 Properties
- 4 Methods
- 4.1 OnNotValid()
- 4.2 IsValid() : Boolean
- 4.3 Refresh()
- 4.4 Delete()
- 4.5 Update()
- 4.6 Create()
- 4.7 Save()
- 4.8 OnLoad(Object id)
- 4.9 OnDelete()
- 4.10 OnUpdate()
- 4.11 OnSave()
- 4.12 FindDirty(Object id, IDictionary previousState, IDictionary currentState, IType[] types) : Int32[]
- 4.13 IsUnsaved() : Object
- 4.14 PostFlush()
- 4.15 PreFlush()
- 4.16 BeforeDelete(IDictionary adapter)
- 4.17 BeforeLoad(IDictionary adapter) : Boolean
- 4.18 BeforeSave(IDictionary state) : Boolean
- 4.19 ToString() : String
- 4.20 Execute(NHibernateDelegate call) : Object
ActiveRecordValidationBase API Document
Extends Castle.ActiveRecord.ActiveRecordBase adding automatic validation support.
Example
public class Customer : ActiveRecordBase { ... [Property, ValidateNotEmpty] public int Name { get { return _name; } set { _name = value; } } [Property, ValidateNotEmpty, ValidateEmail] public int Email { get { return _email; } set { _email = value; } }
Constructors
ActiveRecordValidationBase()
Constructs an ActiveRecordValidationBase
Properties
| Name | Type | Description |
|---|---|---|
| ValidationErrorMessages | String[] | Returns a list of current validation errors messages. |
| PropertiesValidationErrorMessage | IDictionary | Maps a specific PropertyInfo to a list of error messages. Useful for frameworks. |
Methods
OnNotValid()
Throws an exception explaining why the save or update cannot be executed when fields are not ok to pass.
You can override this method to declare a better behavior.
IsValid() : Boolean
Performs the fields validation. Returns true if no validation error was found.
Refresh()
Refresh the instance from the database.
Delete()
Deletes the instance from the database.
Update()
Persists the modification on the instance state to the database.
Create()
Creates (Saves) a new instance to the database.
Save()
Saves the instance information to the database. May Create or Update the instance depending on whether it has a valid ID.
OnLoad(Object id)
Lifecycle method invoked during Load of the entity
| Parameter | Description |
|---|---|
| id | Missing documentation |
OnDelete()
Lifecycle method invoked during Delete of the entity
OnUpdate()
Lifecycle method invoked during Update of the entity
OnSave()
Lifecycle method invoked during Save of the entity
FindDirty(Object id, IDictionary previousState, IDictionary currentState, IType[] types) : Int32[]
Called from Flush(). The return value determines whether the entity is updated
| Parameter | Description |
|---|---|
| id | Missing documentation |
| previousState | Missing documentation |
| currentState | Missing documentation |
| types | Missing documentation |
IsUnsaved() : Object
Called when a transient entity is passed to SaveOrUpdate.
PostFlush()
Called after a flush that actually ends in execution of the SQL statements required to synchronize in-memory state with the database.
PreFlush()
Called before a flush
BeforeDelete(IDictionary adapter)
Hook to perform additional tasks before removing the object instance representation from the database.
| Parameter | Description |
|---|---|
| adapter | Missing documentation |
BeforeLoad(IDictionary adapter) : Boolean
Hook to transform the read data from the database before populating the object instance
| Parameter | Description |
|---|---|
| adapter | Missing documentation |
BeforeSave(IDictionary state) : Boolean
Hook to change the object state before saving it.
| Parameter | Description |
|---|---|
| state | Missing documentation |
ToString() : String
Execute(NHibernateDelegate call) : Object
Invokes the specified delegate passing a valid NHibernate session. Used for custom NHibernate queries.
| Parameter | Description |
|---|---|
| call | Missing documentation |