C# Class Castle.ActiveRecord.ActiveRecordBase

Inheritance: ActiveRecordHooksBase
Afficher le fichier Open project: nats/castle-1.0.3-mono Class Usage Examples

Protected Properties

Свойство Type Description
holder ISessionFactoryHolder

Méthodes publiques

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

Méthodes protégées

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

Private Methods

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

Method Details

Asc() public static méthode

Ascending Order
Returns an array of Ascending Order instances specifing which properties to use to order a result.
public static Asc ( ) : NHibernate.Criterion.Order[]
Résultat NHibernate.Criterion.Order[]

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

Count() protected static méthode

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

Count() protected static méthode

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

Count() protected static méthode

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

Create() public méthode

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

Create() protected static méthode

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

CreateAndFlush() public méthode

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

CreateAndFlush() protected static méthode

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

Delete() public méthode

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

Delete() protected static méthode

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

DeleteAll() protected static méthode

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

DeleteAll() protected static méthode

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

DeleteAll() protected static méthode

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

DeleteAndFlush() public méthode

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

DeleteAndFlush() protected static méthode

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

Desc() public static méthode

Descending Order
Returns an array of Descending Order instances specifing which properties to use to order a result.
public static Desc ( ) : NHibernate.Criterion.Order[]
Résultat NHibernate.Criterion.Order[]

EnumerateQuery() protected static méthode

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

Execute() protected méthode

Invokes the specified delegate passing a valid NHibernate session. Used for custom NHibernate queries.
protected Execute ( NHibernateDelegate call ) : object
call NHibernateDelegate The delegate instance
Résultat object

Execute() protected static méthode

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

ExecuteQuery() public static méthode

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

Exists() protected static méthode

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

Exists() protected static méthode

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

Exists() protected static méthode

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

Exists() protected static méthode

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

FindAll() protected static méthode

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

FindAll() protected static méthode

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

FindAll() protected static méthode

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

FindAllByProperty() protected static méthode

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

FindAllByProperty() protected static méthode

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

FindByPrimaryKey() protected static méthode

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

FindByPrimaryKey() protected static méthode

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

FindFirst() protected static méthode

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

FindFirst() protected static méthode

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

FindFirst() protected static méthode

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
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 ) : 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

Refresh() public méthode

Refresh the instance from the database.
public Refresh ( ) : void
Résultat void

Refresh() protected static méthode

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

Replicate() protected 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.
protected static Replicate ( object instance, NHibernate.ReplicationMode replicationMode ) : void
instance object The instance.
replicationMode NHibernate.ReplicationMode The replication mode.
Résultat void

Save() public méthode

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

Save() protected static méthode

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

SaveAndFlush() public méthode

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

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

protected static SaveAndFlush ( object instance ) : void
instance object The ActiveRecord instance to be saved
Résultat void

SaveCopy() public méthode

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

SaveCopy() protected static méthode

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

SaveCopyAndFlush() public méthode

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

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

protected static SaveCopyAndFlush ( object instance ) : object
instance object The transient instance to be saved
Résultat object

SlicedFindAll() protected static méthode

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

SlicedFindAll() protected static méthode

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

SlicedFindAll() protected static méthode

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

SlicedFindAll() protected static méthode

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

ToString() public méthode

Return the type of the object with its PK value. Useful for logging/debugging
public ToString ( ) : String
Résultat String

Update() public méthode

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

Update() protected static méthode

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

UpdateAndFlush() public méthode

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

UpdateAndFlush() protected static méthode

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

Property Details

holder protected_oe static_oe property

The global holder for the session factories.
protected static ISessionFactoryHolder holder
Résultat ISessionFactoryHolder