C# Class Castle.ActiveRecord.ActiveRecordMediator

Allow programmers to use the ActiveRecord functionality without direct reference to ActiveRecordBase
Show file Open project: nats/castle-1.0.3-mono Class Usage Examples

Public Methods

Method Description
Count ( Type targetType, DetachedCriteria detachedCriteria ) : int

Returns the number of records of the specified type in the database

Count ( Type targetType, string filter ) : int

Returns the number of records of the specified type in the database

Create ( object instance ) : void

Creates (Saves) a new instance to the database.

CreateAndFlush ( object instance ) : void

Creates (Saves) a new instance to the database and flushes the session.

Delete ( object instance ) : void

Deletes the instance from the database.

DeleteAll ( Type targetType, IEnumerable pkValues ) : int

Deletes all targetType objects, based on the primary keys supplied on pkValues.

DeleteAll ( Type type ) : void

Deletes all entities of the specified type (and their inheritors)

DeleteAll ( Type type, string where ) : void

Deletes all entities of specified type that match the HQL where clause

DeleteAndFlush ( object instance ) : void

Deletes the instance from the database and flushes the session.

EnumerateQuery ( IActiveRecordQuery q ) : IEnumerable

Enumerates the query. Note: Only use if you expect most of the values to be on the second level cache

Execute ( Type targetType, NHibernateDelegate call, object instance ) : object

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

ExecuteQuery ( IActiveRecordQuery q ) : object

Executes the query

Exists ( Type targetType ) : bool

Check if there is any records in the db for the target type

Exists ( Type targetType, DetachedCriteria detachedCriteria ) : bool

Check if any instance matching the criteria exists in the database.

Exists ( Type targetType, object id ) : bool

Check if the id exists in the database.

Exists ( Type targetType, string filter ) : bool

Check if there is any records in the db for the target type

FindAll ( Type targetType ) : Array

Returns all instances found for the specified type.

FindAll ( Type targetType, DetachedCriteria detachedCriteria ) : Array

Returns all instances found for the specified type according to the criteria

FindAll ( Type targetType, NHibernate.Criterion.Order orders ) : Array

Returns all instances found for the specified type using sort orders and criterias.

FindAllByProperty ( Type targetType, String orderByColumn, String property, object value ) : Array

Finds records based on a property value - automatically converts null values to IS NULL style queries.

FindAllByProperty ( Type targetType, String property, object value ) : Array

Finds records based on a property value - automatically converts null values to IS NULL style queries.

FindByPrimaryKey ( Type targetType, object id ) : object

Finds an object instance by its primary key.

FindByPrimaryKey ( Type targetType, object id, bool throwOnNotFound ) : object

Finds an object instance by its primary key.

FindFirst ( Type targetType ) : object

Searches and returns the first row.

FindFirst ( Type targetType, DetachedCriteria detachedCriteria ) : object

Searches and returns the first row.

FindFirst ( Type targetType, NHibernate.Criterion.Order orders ) : object

Searches and returns the first row.

FindOne ( Type targetType ) : object

Searches and returns the a row. If more than one is found, throws ActiveRecordException

GetSessionFactoryHolder ( ) : ISessionFactoryHolder

Testing hock only.

Refresh ( object instance ) : void

Refresh the instance from the database.

Replicate ( object instance, NHibernate.ReplicationMode replicationMode ) : void

From NHibernate documentation: Persist all reachable transient objects, reusing the current identifier values. Note that this will not trigger the Interceptor of the Session.

Save ( object instance ) : void

Saves the instance to the database

SaveAndFlush ( object instance ) : void

Saves the instance to the database and flushes the session. If the primary key is unitialized it creates the instance on the database. Otherwise it updates it.

If the primary key is assigned, then you must invoke Create(object) or Update(object) instead.

SaveCopy ( object instance ) : object

Saves a copy of instance to the database

SaveCopyAndFlush ( object instance ) : void

Saves a copy of the instance to the database and flushes the session. If the primary key is unitialized it creates the instance on the database. Otherwise it updates it.

If the primary key is assigned, then you must invoke Create(object) or Update(object) instead.

SlicedFindAll ( Type targetType, int firstResult, int maxresults ) : Array

Returns a portion of the query results (sliced)

SlicedFindAll ( Type targetType, int firstResult, int maxResults, DetachedCriteria criteria ) : Array

Returns a portion of the query results (sliced)

SlicedFindAll ( Type targetType, int firstResult, int maxresults, NHibernate.Criterion.Order orders ) : Array

Returns a portion of the query results (sliced)

SlicedFindAll ( Type targetType, int firstResult, int maxResults, NHibernate.Criterion.Order orders, DetachedCriteria criteria ) : Array

Returns a portion of the query results (sliced)

Update ( object instance ) : void

Persists the modification on the instance state to the database.

UpdateAndFlush ( object instance ) : void

Persists the modification on the instance state to the database and flushes the session.

Protected Methods

Method Description
Count ( Type targetType ) : int

Returns the number of records of the specified type in the database

FindOne ( Type targetType, DetachedCriteria criteria ) : object

Searches and returns a row. If more than one is found, throws ActiveRecordException

Method Details

Count() protected static method

Returns the number of records of the specified type in the database
protected static Count ( Type targetType ) : int
targetType System.Type Type of the target.
return int

Count() public static method

Returns the number of records of the specified type in the database
public static Count ( Type targetType, DetachedCriteria detachedCriteria ) : int
targetType System.Type The target type.
detachedCriteria DetachedCriteria The criteria expression
return int

Count() public static method

Returns the number of records of the specified type in the database
public static Count ( Type targetType, string filter ) : int
targetType System.Type Type of the target.
filter string A sql where string i.e. Person=? and DOB > ?
return int

Create() public static method

Creates (Saves) a new instance to the database.
public static Create ( object instance ) : void
instance object The ActiveRecord instance to be deleted
return void

CreateAndFlush() public static method

Creates (Saves) a new instance to the database and flushes the session.
public static CreateAndFlush ( object instance ) : void
instance object The ActiveRecord instance to be created on the database
return void

Delete() public static method

Deletes the instance from the database.
public static Delete ( object instance ) : void
instance object The ActiveRecord instance to be deleted
return void

DeleteAll() public static method

Deletes all targetType objects, based on the primary keys supplied on pkValues.
public static DeleteAll ( Type targetType, IEnumerable pkValues ) : int
targetType System.Type The target ActiveRecord type
pkValues IEnumerable A list of primary keys
return int

DeleteAll() public static method

Deletes all entities of the specified type (and their inheritors)
public static DeleteAll ( Type type ) : void
type System.Type The type.
return void

DeleteAll() public static method

Deletes all entities of specified type that match the HQL where clause
public static DeleteAll ( Type type, string where ) : void
type System.Type The type.
where string The where.
return void

DeleteAndFlush() public static method

Deletes the instance from the database and flushes the session.
public static DeleteAndFlush ( object instance ) : void
instance object The ActiveRecord instance to be deleted
return void

EnumerateQuery() public static method

Enumerates the query. Note: Only use if you expect most of the values to be on the second level cache
public static EnumerateQuery ( IActiveRecordQuery q ) : IEnumerable
q IActiveRecordQuery The query
return IEnumerable

Execute() public static method

Invokes the specified delegate passing a valid NHibernate session. Used for custom NHibernate queries.
public static Execute ( Type targetType, NHibernateDelegate call, object instance ) : object
targetType System.Type The target ActiveRecordType
call NHibernateDelegate The delegate instance
instance object The ActiveRecord instance
return object

ExecuteQuery() public static method

Executes the query
public static ExecuteQuery ( IActiveRecordQuery q ) : object
q IActiveRecordQuery The query
return object

Exists() public static method

Check if there is any records in the db for the target type
public static Exists ( Type targetType ) : bool
targetType System.Type Type of the target.
return bool

Exists() public static method

Check if any instance matching the criteria exists in the database.
public static Exists ( Type targetType, DetachedCriteria detachedCriteria ) : bool
targetType System.Type The target type.
detachedCriteria DetachedCriteria The criteria expression
return bool

Exists() public static method

Check if the id exists in the database.
public static Exists ( Type targetType, object id ) : bool
targetType System.Type Type of the target.
id object The id to check on
return bool

Exists() public static method

Check if there is any records in the db for the target type
public static Exists ( Type targetType, string filter ) : bool
targetType System.Type Type of the target.
filter string A sql where string i.e. Person=? and DOB > ?
return bool

FindAll() public static method

Returns all instances found for the specified type.
public static FindAll ( Type targetType ) : Array
targetType System.Type
return System.Array

FindAll() public static method

Returns all instances found for the specified type according to the criteria
public static FindAll ( Type targetType, DetachedCriteria detachedCriteria ) : Array
targetType System.Type
detachedCriteria DetachedCriteria
return System.Array

FindAll() public static method

Returns all instances found for the specified type using sort orders and criterias.
public static FindAll ( Type targetType, NHibernate.Criterion.Order orders ) : Array
targetType System.Type
orders NHibernate.Criterion.Order
return System.Array

FindAllByProperty() public static method

Finds records based on a property value - automatically converts null values to IS NULL style queries.
public static FindAllByProperty ( Type targetType, String orderByColumn, String property, object value ) : Array
targetType System.Type The target type
orderByColumn String The column name to be ordered ASC
property String A property name (not a column name)
value object The value to be equals to
return System.Array

FindAllByProperty() public static method

Finds records based on a property value - automatically converts null values to IS NULL style queries.
public static FindAllByProperty ( Type targetType, String property, object value ) : Array
targetType System.Type The target type
property String A property name (not a column name)
value object The value to be equals to
return System.Array

FindByPrimaryKey() public static method

Finds an object instance by its primary key.
public static FindByPrimaryKey ( Type targetType, object id ) : object
targetType System.Type The AR subclass type
id object ID value
return object

FindByPrimaryKey() public static method

Finds an object instance by its primary key.
if throwOnNotFound is set to /// true and the row is not found
public static FindByPrimaryKey ( Type targetType, object id, bool throwOnNotFound ) : object
targetType System.Type The AR subclass type
id object ID value
throwOnNotFound bool true if you want an exception to be thrown /// if the object is not found
return object

FindFirst() public static method

Searches and returns the first row.
public static FindFirst ( Type targetType ) : object
targetType System.Type The target type
return object

FindFirst() public static method

Searches and returns the first row.
public static FindFirst ( Type targetType, DetachedCriteria detachedCriteria ) : object
targetType System.Type The target type.
detachedCriteria DetachedCriteria The criteria.
return object

FindFirst() public static method

Searches and returns the first row.
public static FindFirst ( Type targetType, NHibernate.Criterion.Order orders ) : object
targetType System.Type The target type
orders NHibernate.Criterion.Order The sort order - used to determine which record is the first one
return object

FindOne() public static method

Searches and returns the a row. If more than one is found, throws ActiveRecordException
public static FindOne ( Type targetType ) : object
targetType System.Type The target type
return object

FindOne() protected static method

Searches and returns a row. If more than one is found, throws ActiveRecordException
protected static FindOne ( Type targetType, DetachedCriteria criteria ) : object
targetType System.Type The target type
criteria DetachedCriteria The criteria
return object

GetSessionFactoryHolder() public static method

Testing hock only.
public static GetSessionFactoryHolder ( ) : ISessionFactoryHolder
return ISessionFactoryHolder

Refresh() public static method

Refresh the instance from the database.
public static Refresh ( object instance ) : void
instance object The ActiveRecord instance to be reloaded
return void

Replicate() public static method

From NHibernate documentation: Persist all reachable transient objects, reusing the current identifier values. Note that this will not trigger the Interceptor of the Session.
public static Replicate ( object instance, NHibernate.ReplicationMode replicationMode ) : void
instance object The instance.
replicationMode NHibernate.ReplicationMode The replication mode.
return void

Save() public static method

Saves the instance to the database
public static Save ( object instance ) : void
instance object The ActiveRecord instance to be deleted
return void

SaveAndFlush() public static method

Saves the instance to the database and flushes the session. If the primary key is unitialized it creates the instance on the database. Otherwise it updates it.

If the primary key is assigned, then you must invoke Create(object) or Update(object) instead.

public static SaveAndFlush ( object instance ) : void
instance object The ActiveRecord instance to be saved
return void

SaveCopy() public static method

Saves a copy of instance to the database
public static SaveCopy ( object instance ) : object
instance object The transient instance to be copied
return object

SaveCopyAndFlush() public static method

Saves a copy of the instance to the database and flushes the session. If the primary key is unitialized it creates the instance on the database. Otherwise it updates it.

If the primary key is assigned, then you must invoke Create(object) or Update(object) instead.

public static SaveCopyAndFlush ( object instance ) : void
instance object The transient instance to be copied
return void

SlicedFindAll() public static method

Returns a portion of the query results (sliced)
public static SlicedFindAll ( Type targetType, int firstResult, int maxresults ) : Array
targetType System.Type
firstResult int
maxresults int
return System.Array

SlicedFindAll() public static method

Returns a portion of the query results (sliced)
public static SlicedFindAll ( Type targetType, int firstResult, int maxResults, DetachedCriteria criteria ) : Array
targetType System.Type
firstResult int
maxResults int
criteria DetachedCriteria
return System.Array

SlicedFindAll() public static method

Returns a portion of the query results (sliced)
public static SlicedFindAll ( Type targetType, int firstResult, int maxresults, NHibernate.Criterion.Order orders ) : Array
targetType System.Type
firstResult int
maxresults int
orders NHibernate.Criterion.Order
return System.Array

SlicedFindAll() public static method

Returns a portion of the query results (sliced)
public static SlicedFindAll ( Type targetType, int firstResult, int maxResults, NHibernate.Criterion.Order orders, DetachedCriteria criteria ) : Array
targetType System.Type
firstResult int
maxResults int
orders NHibernate.Criterion.Order
criteria DetachedCriteria
return System.Array

Update() public static method

Persists the modification on the instance state to the database.
public static Update ( object instance ) : void
instance object The ActiveRecord instance to be deleted
return void

UpdateAndFlush() public static method

Persists the modification on the instance state to the database and flushes the session.
public static UpdateAndFlush ( object instance ) : void
instance object The ActiveRecord instance to be updated on the database
return void