C# Класс Castle.ActiveRecord.ActiveRecordMediator

Allow programmers to use the ActiveRecord functionality without direct reference to ActiveRecordBase
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
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

Описание методов

Count() защищенный статический Метод

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.
Результат int

Count() публичный статический Метод

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
Результат int

Count() публичный статический Метод

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 > ?
Результат int

Create() публичный статический Метод

Creates (Saves) a new instance to the database.
public static Create ( object instance ) : void
instance object The ActiveRecord instance to be deleted
Результат void

CreateAndFlush() публичный статический Метод

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
Результат void

Delete() публичный статический Метод

Deletes the instance from the database.
public static Delete ( object instance ) : void
instance object The ActiveRecord instance to be deleted
Результат void

DeleteAll() публичный статический Метод

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
Результат int

DeleteAll() публичный статический Метод

Deletes all entities of the specified type (and their inheritors)
public static DeleteAll ( Type type ) : void
type System.Type The type.
Результат void

DeleteAll() публичный статический Метод

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.
Результат void

DeleteAndFlush() публичный статический Метод

Deletes the instance from the database and flushes the session.
public static DeleteAndFlush ( object instance ) : void
instance object The ActiveRecord instance to be deleted
Результат void

EnumerateQuery() публичный статический Метод

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
Результат IEnumerable

Execute() публичный статический Метод

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
Результат object

ExecuteQuery() публичный статический Метод

Executes the query
public static ExecuteQuery ( IActiveRecordQuery q ) : object
q IActiveRecordQuery The query
Результат object

Exists() публичный статический Метод

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.
Результат bool

Exists() публичный статический Метод

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
Результат bool

Exists() публичный статический Метод

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
Результат bool

Exists() публичный статический Метод

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 > ?
Результат bool

FindAll() публичный статический Метод

Returns all instances found for the specified type.
public static FindAll ( Type targetType ) : Array
targetType System.Type
Результат System.Array

FindAll() публичный статический Метод

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
Результат System.Array

FindAll() публичный статический Метод

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
Результат System.Array

FindAllByProperty() публичный статический Метод

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
Результат System.Array

FindAllByProperty() публичный статический Метод

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
Результат System.Array

FindByPrimaryKey() публичный статический Метод

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
Результат object

FindByPrimaryKey() публичный статический Метод

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
Результат object

FindFirst() публичный статический Метод

Searches and returns the first row.
public static FindFirst ( Type targetType ) : object
targetType System.Type The target type
Результат object

FindFirst() публичный статический Метод

Searches and returns the first row.
public static FindFirst ( Type targetType, DetachedCriteria detachedCriteria ) : object
targetType System.Type The target type.
detachedCriteria DetachedCriteria The criteria.
Результат object

FindFirst() публичный статический Метод

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
Результат object

FindOne() публичный статический Метод

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
Результат object

FindOne() защищенный статический Метод

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
Результат object

GetSessionFactoryHolder() публичный статический Метод

Testing hock only.
public static GetSessionFactoryHolder ( ) : ISessionFactoryHolder
Результат ISessionFactoryHolder

Refresh() публичный статический Метод

Refresh the instance from the database.
public static Refresh ( object instance ) : void
instance object The ActiveRecord instance to be reloaded
Результат void

Replicate() публичный статический Метод

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.
Результат void

Save() публичный статический Метод

Saves the instance to the database
public static Save ( object instance ) : void
instance object The ActiveRecord instance to be deleted
Результат void

SaveAndFlush() публичный статический Метод

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
Результат void

SaveCopy() публичный статический Метод

Saves a copy of instance to the database
public static SaveCopy ( object instance ) : object
instance object The transient instance to be copied
Результат object

SaveCopyAndFlush() публичный статический Метод

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
Результат void

SlicedFindAll() публичный статический Метод

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
Результат System.Array

SlicedFindAll() публичный статический Метод

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
Результат System.Array

SlicedFindAll() публичный статический Метод

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
Результат System.Array

SlicedFindAll() публичный статический Метод

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
Результат System.Array

Update() публичный статический Метод

Persists the modification on the instance state to the database.
public static Update ( object instance ) : void
instance object The ActiveRecord instance to be deleted
Результат void

UpdateAndFlush() публичный статический Метод

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
Результат void