Home

Castle Stronghold

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

NameTypeDescription
ValidationErrorMessagesString[] Returns a list of current validation errors messages.
PropertiesValidationErrorMessageIDictionary 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.

Quick Note

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

ParameterDescription
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

ParameterDescription
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.

ParameterDescription
adapter Missing documentation

BeforeLoad(IDictionary adapter) : Boolean

Hook to transform the read data from the database before populating the object instance

ParameterDescription
adapter Missing documentation

BeforeSave(IDictionary state) : Boolean

Hook to change the object state before saving it.

ParameterDescription
state Missing documentation

ToString() : String

Execute(NHibernateDelegate call) : Object

Invokes the specified delegate passing a valid NHibernate session. Used for custom NHibernate queries.

ParameterDescription
call Missing documentation

Google
Search WWW Search castleproject.org