C# Class Castle.ActiveRecord.ActiveRecordMediator

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

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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 méthode

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.
Résultat int

Count() public static méthode

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
Résultat int

Count() public static méthode

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 > ?
Résultat int

Create() public static méthode

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

CreateAndFlush() public static méthode

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
Résultat void

Delete() public static méthode

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

DeleteAll() public static méthode

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
Résultat int

DeleteAll() public static méthode

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

DeleteAll() public static méthode

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.
Résultat void

DeleteAndFlush() public static méthode

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

EnumerateQuery() public static méthode

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
Résultat IEnumerable

Execute() public static méthode

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
Résultat object

ExecuteQuery() public static méthode

Executes the query
public static ExecuteQuery ( IActiveRecordQuery q ) : object
q IActiveRecordQuery The query
Résultat object

Exists() public static méthode

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.
Résultat bool

Exists() public static méthode

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
Résultat bool

Exists() public static méthode

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
Résultat bool

Exists() public static méthode

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 > ?
Résultat bool

FindAll() public static méthode

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

FindAll() public static méthode

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
Résultat System.Array

FindAll() public static méthode

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
Résultat System.Array

FindAllByProperty() public static méthode

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
Résultat System.Array

FindAllByProperty() public static méthode

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
Résultat System.Array

FindByPrimaryKey() public static méthode

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
Résultat object

FindByPrimaryKey() public static méthode

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
Résultat object

FindFirst() public static méthode

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

FindFirst() public static méthode

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

FindFirst() public static méthode

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
Résultat object

FindOne() public static méthode

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
Résultat object

FindOne() protected static méthode

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
Résultat object

GetSessionFactoryHolder() public static méthode

Testing hock only.
public static GetSessionFactoryHolder ( ) : ISessionFactoryHolder
Résultat ISessionFactoryHolder

Refresh() public static méthode

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

Replicate() public static méthode

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.
Résultat void

Save() public static méthode

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

SaveAndFlush() public static méthode

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
Résultat void

SaveCopy() public static méthode

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

SaveCopyAndFlush() public static méthode

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
Résultat void

SlicedFindAll() public static méthode

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
Résultat System.Array

SlicedFindAll() public static méthode

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
Résultat System.Array

SlicedFindAll() public static méthode

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
Résultat System.Array

SlicedFindAll() public static méthode

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
Résultat System.Array

Update() public static méthode

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

UpdateAndFlush() public static méthode

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
Résultat void