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

Наследование: ActiveRecordHooksBase
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
holder ISessionFactoryHolder

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

Метод Описание
Asc ( ) : NHibernate.Criterion.Order[]

Ascending Order

Returns an array of Ascending Order instances specifing which properties to use to order a result.

Create ( ) : void

Creates (Saves) a new instance to the database.

If within a SessionScope the operation is going to be on hold until NHibernate (or you) decides to flush the session.

CreateAndFlush ( ) : void

Creates (Saves) a new instance to the database.

Even within a SessionScope the operation is going to be flushed immediately. This might have side effects such as flushing (persisting) others operations that were on hold.

Delete ( ) : void

Deletes the instance from the database.

If within a SessionScope the operation is going to be on hold until NHibernate (or you) decides to flush the session.

DeleteAndFlush ( ) : void

Deletes the instance from the database.

Even within a SessionScope the operation is going to be flushed immediately. This might have side effects such as flushing (persisting) others operations that were on hold.

Desc ( ) : NHibernate.Criterion.Order[]

Descending Order

Returns an array of Descending Order instances specifing which properties to use to order a result.

ExecuteQuery ( IActiveRecordQuery query ) : object

Executes the query.

Refresh ( ) : void

Refresh the instance from the database.

Save ( ) : void

Saves the instance information to the database. May Create or Update the instance depending on whether it has a valid ID.

If within a SessionScope the operation is going to be on hold until NHibernate (or you) decides to flush the session.

SaveAndFlush ( ) : void

Saves the instance information to the database. May Create or Update the instance depending on whether it has a valid ID.

Even within a SessionScope the operation is going to be flushed immediately. This might have side effects such as flushing (persisting) others operations that were on hold.

SaveCopy ( ) : object

Saves a copy of the instance information to the database. May Create or Update the instance depending on whether it has a valid ID.

If within a SessionScope the operation is going to be on hold until NHibernate (or you) decides to flush the session.

SaveCopyAndFlush ( ) : object

Saves a copy of the instance information to the database. May Create or Update the instance depending on whether it has a valid ID.

Even within a SessionScope the operation is going to be flushed immediately. This might have side effects such as flushing (persisting) others operations that were on hold.

ToString ( ) : String

Return the type of the object with its PK value. Useful for logging/debugging

Update ( ) : void

Persists the modification on the instance state to the database.

If within a SessionScope the operation is going to be on hold until NHibernate (or you) decides to flush the session.

UpdateAndFlush ( ) : void

Persists the modification on the instance state to the database.

Even within a SessionScope the operation is going to be flushed immediately. This might have side effects such as flushing (persisting) others operations that were on hold.

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

Метод Описание
Count ( Type targetType ) : int

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

Count ( Type targetType, DetachedCriteria detachedCriteria ) : int

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

Count ( Type targetType, ICriterion criteria ) : 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 rows for the specified ActiveRecord type

This method is usually useful for test cases.

DeleteAll ( Type type, String where ) : void

Deletes all rows for the specified ActiveRecord type that matches the supplied HQL condition

This method is usually useful for test cases.

DeleteAndFlush ( object instance ) : void

Deletes the instance from the database and flushes the session.

EnumerateQuery ( IActiveRecordQuery query ) : IEnumerable

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

Execute ( NHibernateDelegate call ) : object

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

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

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

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

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 an unique ID

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

Finds an object instance by an unique ID

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 a row. If more than one is found, throws ActiveRecordException

FindOne ( Type targetType, DetachedCriteria criteria ) : object

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

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. 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() or Update() instead.

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() or Update() instead.

SaveCopy ( object instance ) : object

Saves a copy of the instance to the database. 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() or Update() instead.

SaveCopyAndFlush ( object instance ) : object

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() or Update() 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.

Приватные методы

Метод Описание
AddOrdersToCriteria ( ICriteria criteria, IEnumerable orders ) : void
EnsureInitialized ( Type type ) : void
GetModel ( Type arType ) : ActiveRecordModel

Internally used

InternalCreate ( object instance, bool flush ) : void

Creates (Saves) a new instance to the database.

InternalDelete ( object instance, bool flush ) : void

Deletes the instance from the database.

InternalSave ( object instance, bool flush ) : void

Saves the instance to the database. 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() or Update() instead.

InternalSaveCopy ( object instance, bool flush ) : object

Saves a copy of the instance to the database. 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() or Update() instead.

InternalUpdate ( object instance, bool flush ) : void

Persists the modification on the instance state to the database.

PropertyNamesToOrderArray ( bool asc ) : NHibernate.Criterion.Order[]
Register ( Type arType, ActiveRecordModel model ) : void

Internally used

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

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

Ascending Order
Returns an array of Ascending Order instances specifing which properties to use to order a result.
public static Asc ( ) : NHibernate.Criterion.Order[]
Результат NHibernate.Criterion.Order[]

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

Returns the number of records of the specified type in the database
protected static Count ( Type targetType ) : int
targetType System.Type The target type.
Результат int

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

Returns the number of records of the specified type in the database
protected 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
protected static Count ( Type targetType, ICriterion criteria ) : int
targetType System.Type The target type.
criteria ICriterion The criteria expression
Результат int

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

Returns the number of records of the specified type in the database
protected static Count ( Type targetType, string filter ) : int
targetType System.Type The target type.
filter string A sql where string i.e. Person=? and DOB > ?
Результат int

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

Creates (Saves) a new instance to the database.
If within a SessionScope the operation is going to be on hold until NHibernate (or you) decides to flush the session.
public Create ( ) : void
Результат void

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

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

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

Creates (Saves) a new instance to the database.
Even within a SessionScope the operation is going to be flushed immediately. This might have side effects such as flushing (persisting) others operations that were on hold.
public CreateAndFlush ( ) : void
Результат void

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

Creates (Saves) a new instance to the database and flushes the session.
protected static CreateAndFlush ( object instance ) : void
instance object The ActiveRecord instance to be created on the database
Результат void

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

Deletes the instance from the database.
If within a SessionScope the operation is going to be on hold until NHibernate (or you) decides to flush the session.
public Delete ( ) : void
Результат void

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

Deletes the instance from the database.
protected 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.
protected 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 rows for the specified ActiveRecord type
This method is usually useful for test cases.
protected static DeleteAll ( Type type ) : void
type System.Type ActiveRecord type on which the rows on the database should be deleted
Результат void

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

Deletes all rows for the specified ActiveRecord type that matches the supplied HQL condition
This method is usually useful for test cases.
protected static DeleteAll ( Type type, String where ) : void
type System.Type ActiveRecord type on which the rows on the database should be deleted
where String HQL condition to select the rows to be deleted
Результат void

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

Deletes the instance from the database.
Even within a SessionScope the operation is going to be flushed immediately. This might have side effects such as flushing (persisting) others operations that were on hold.
public DeleteAndFlush ( ) : void
Результат void

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

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

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

Descending Order
Returns an array of Descending Order instances specifing which properties to use to order a result.
public static Desc ( ) : NHibernate.Criterion.Order[]
Результат NHibernate.Criterion.Order[]

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

Enumerates the query Note: only use if you expect most of the values to exist on the second level cache.
protected static EnumerateQuery ( IActiveRecordQuery query ) : IEnumerable
query IActiveRecordQuery The query.
Результат IEnumerable

Execute() защищенный Метод

Invokes the specified delegate passing a valid NHibernate session. Used for custom NHibernate queries.
protected Execute ( NHibernateDelegate call ) : object
call NHibernateDelegate The delegate instance
Результат object

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

Invokes the specified delegate passing a valid NHibernate session. Used for custom NHibernate queries.
protected 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 query ) : object
query IActiveRecordQuery The query.
Результат object

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

Check if there is any records in the db for the target type
protected static Exists ( Type targetType ) : bool
targetType System.Type The target type.
Результат bool

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

Check if any instance matching the criteria exists in the database.
protected 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.
protected static Exists ( Type targetType, object id ) : bool
targetType System.Type The target type.
id object The id to check on
Результат bool

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

Check if there is any records in the db for the target type
protected static Exists ( Type targetType, string filter ) : bool
targetType System.Type The target type.
filter string A sql where string i.e. Person=? and DOB > ?
Результат bool

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

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

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

Returns all instances found for the specified type according to the criteria
protected static FindAll ( Type targetType, DetachedCriteria detachedCriteria ) : Array
targetType System.Type The target type.
detachedCriteria DetachedCriteria The criteria.
Результат System.Array

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

Returns all instances found for the specified type using sort orders and criteria.
protected static FindAll ( Type targetType, NHibernate.Criterion.Order orders ) : Array
targetType System.Type The The target type.
orders NHibernate.Criterion.Order An of objects.
Результат System.Array

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

Finds records based on a property value - automatically converts null values to IS NULL style queries.
protected 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.
protected 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 an unique ID
protected 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 an unique ID
if throwOnNotFound is set to /// true and the row is not found
protected 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 to catch an exception /// if the object is not found
Результат object

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

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

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

Searches and returns the first row.
protected 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.
protected 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 a row. If more than one is found, throws ActiveRecordException
protected 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

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

Refresh the instance from the database.
public Refresh ( ) : void
Результат void

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

Refresh the instance from the database.
protected 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.
protected static Replicate ( object instance, NHibernate.ReplicationMode replicationMode ) : void
instance object The instance.
replicationMode NHibernate.ReplicationMode The replication mode.
Результат void

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

Saves the instance information to the database. May Create or Update the instance depending on whether it has a valid ID.
If within a SessionScope the operation is going to be on hold until NHibernate (or you) decides to flush the session.
public Save ( ) : void
Результат void

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

Saves the instance to the database. 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() or Update() instead.

protected static Save ( object instance ) : void
instance object The ActiveRecord instance to be saved
Результат void

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

Saves the instance information to the database. May Create or Update the instance depending on whether it has a valid ID.
Even within a SessionScope the operation is going to be flushed immediately. This might have side effects such as flushing (persisting) others operations that were on hold.
public SaveAndFlush ( ) : void
Результат 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() or Update() instead.

protected static SaveAndFlush ( object instance ) : void
instance object The ActiveRecord instance to be saved
Результат void

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

Saves a copy of the instance information to the database. May Create or Update the instance depending on whether it has a valid ID.
If within a SessionScope the operation is going to be on hold until NHibernate (or you) decides to flush the session.
public SaveCopy ( ) : object
Результат object

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

Saves a copy of the instance to the database. 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() or Update() instead.

protected static SaveCopy ( object instance ) : object
instance object The transient instance to be saved
Результат object

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

Saves a copy of the instance information to the database. May Create or Update the instance depending on whether it has a valid ID.
Even within a SessionScope the operation is going to be flushed immediately. This might have side effects such as flushing (persisting) others operations that were on hold.
public SaveCopyAndFlush ( ) : object
Результат 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() or Update() instead.

protected static SaveCopyAndFlush ( object instance ) : object
instance object The transient instance to be saved
Результат object

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

Returns a portion of the query results (sliced)
protected static SlicedFindAll ( Type targetType, int firstResult, int maxResults ) : Array
targetType System.Type The target type.
firstResult int The number of the first row to retrieve.
maxResults int The maximum number of results retrieved.
Результат System.Array

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

Returns a portion of the query results (sliced)
protected static SlicedFindAll ( Type targetType, int firstResult, int maxResults, DetachedCriteria criteria ) : Array
targetType System.Type The target type.
firstResult int The number of the first row to retrieve.
maxResults int The maximum number of results retrieved.
criteria DetachedCriteria The criteria expression
Результат System.Array

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

Returns a portion of the query results (sliced)
protected static SlicedFindAll ( Type targetType, int firstResult, int maxResults, NHibernate.Criterion.Order orders ) : Array
targetType System.Type The target type.
firstResult int The number of the first row to retrieve.
maxResults int The maximum number of results retrieved.
orders NHibernate.Criterion.Order An of objects.
Результат System.Array

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

Returns a portion of the query results (sliced)
protected static SlicedFindAll ( Type targetType, int firstResult, int maxResults, NHibernate.Criterion.Order orders, DetachedCriteria criteria ) : Array
targetType System.Type The target type.
firstResult int The number of the first row to retrieve.
maxResults int The maximum number of results retrieved.
orders NHibernate.Criterion.Order An of objects.
criteria DetachedCriteria The criteria expression
Результат System.Array

ToString() публичный Метод

Return the type of the object with its PK value. Useful for logging/debugging
public ToString ( ) : String
Результат String

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

Persists the modification on the instance state to the database.
If within a SessionScope the operation is going to be on hold until NHibernate (or you) decides to flush the session.
public Update ( ) : void
Результат void

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

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

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

Persists the modification on the instance state to the database.
Even within a SessionScope the operation is going to be flushed immediately. This might have side effects such as flushing (persisting) others operations that were on hold.
public UpdateAndFlush ( ) : void
Результат void

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

Persists the modification on the instance state to the database and flushes the session.
protected static UpdateAndFlush ( object instance ) : void
instance object The ActiveRecord instance to be updated on the database
Результат void

Описание свойств

holder защищенное статическое свойство

The global holder for the session factories.
protected static ISessionFactoryHolder holder
Результат ISessionFactoryHolder