Castle.ActiveRecord Validate that the property's value is unique in the database when saved Initializes a new instance of the class. Initializes a new instance of the class. The error message. Constructs and configures an instance based on the properties set on the attribute instance. Associate meta information related to the desired table mapping. [ActiveRecord("tb_Order")] public class Order : ActiveRecordBase { } If no table is specified, the class name is used as table name Implement common properties shared by some attributes Base class that allows specifying an access strategy to get/set the value for an object' property. Gets or sets the access strategy for this property Gets or sets the custom access strategy The custom access. Gets the access strategy string for NHibernate's mapping. The access string. Gets or sets the cache strategy to use for this property Gets or sets the a name for a cache region. The cache region name. Uses the class name as table name Associates the specified table with the target type Associates the specified table and schema with the target type Gets or sets the table name associated with the type Gets or sets the schema name associated with the type Associates a proxy type with the target type Gets or sets the Discriminator column for a table inheritance modeling Gets or sets the column type (like string or integer) for the discriminator column Gets or sets the value that represents the target class on the discriminator column Gets or sets the length of the discriminator column (valid for string type only) SQL condition to retrieve objects Enable lazy loading for the type Gets a value indicating whether explicit lazy behavior was specified. If explicit lazy behavior was not specified, it goes to the configuration to decide if the type should be lazy or not. From NHibernate documentation: Specifies that UPDATE SQL should be generated at runtime and contain only those columns whose values have changed. From NHibernate documentation: Specifies that INSERT SQL should be generated at runtime and contain only the columns whose values are not null. From NHibernate documentation: Specifies a custom . From NHibernate documentation: Specifies that NHibernate should never perform an SQL UPDATE unless it is certain that an object is actually modified. In certain cases (actually, only when a transient object has been associated with a new session using update()), this means that NHibernate will perform an extra SQL SELECT to determine if an UPDATE is actually required. From NHibernate documentation: Determines whether implicit or explicit query polymorphism is used. From NHibernate documentation: Specifies that instances of the class are (not) mutable. From NHibernate documentation: Specify a "batch size" for fetching instances of this class by identifier. From NHibernate documentation: Determines the optimistic locking strategy. From NHibernate documentation: The auto-import attribute lets us use unqualified class names in the query language, by default. The assembly and namespace attributes specify the assembly where persistent classes are located and the namespace they are declared in. Denotes that the specific class - which is an subclass should not be processed by the framework This attribute is used to create <any/> assoication, a polymorphic assoication to classes that do not share a common base class. Assuming we have two classes that implement IPayment, CreditCard and BankAccount, and we want a property that can point ot either one of them. We can map it like this: [Any(typeof (long), MetaType=typeof (string), TypeColumn="BILLING_DETAILS_TYPE", IdColumn="BILLING_DETAILS_ID", Cascade=CascadeEnum.SaveUpdate)] [Any.MetaValue("CREDIT_CARD", typeof (CreditCard))] [Any.MetaValue("BANK_ACCOUNT", typeof (BankAccount))] public IPayment Payment { get { ... } set { ... } } The [Any] attribute specify that the id type is long, that the meta type (the type that specify the type of the class) is string. The TypeColumn = "BILLING_DETAILS_TYPE" means that Active Record will look in this column to figure out what the type of the associated entity is. The IdColumn = "BILLING_DETAILS_ID" means that Active Record will use this column in conjuction with the type of the entity to find the relevant entity. This is the id of the associated entity (which can point to either back account or credit card). Cascade has the usual semantics. [Any.MetaValue("CREDIT_CARD", typeof (CreditCard))] - means that when Active Record encounters a "CREDIT_CARD" value in the "BILLING_DETAILS_TYPE", is assumes that the id in the "BILLING_DETAILS_ID" is the id of a CreditCard entity. [Any.MetaValue("BANK_ACCOUNT", typeof (BankAccount))] - same, just for "BANK_ACCOUNT" meaning that the id in "BILLING_DETAILS_ID" is an id of a bank account. This is supplied for advanced sceanrios. Initializes a new instance of the class. Using this constructor defaults the idType to Int32 Initializes a new instance of the class. Type of the id. Gets or sets the type of the id. The type of the id. Gets or sets the type of the meta column The type of the meta. Gets or sets the cascade options The cascade. Gets or sets the type column name The type column. Gets or sets the id column name The id column. Gets or sets the index column name The index. Gets or sets a value indicating whether the column should be inserted when inserting. true if should insert; otherwise, false. Gets or sets a value indicating whether the column should be is updated when updating. true if should update; otherwise, false. Gets or sets a value indicating whether this property cannot be null. true if this property cannot be null; otherwise, false. Avoids the AnyAttribute.MetaValue syntax This is used to specify a meta value in an [Any] assoication Any.MetaValue is used to connect a value (such as "CREDIT_CARD") to its type ( typeof(CreditCard) ). Initializes a new instance of the class. The value. The clazz. This is here so the XmlGenerationVisitor will always output the meta-values in consistent order, to aid the tests. Gets or sets the value for this class The value. Gets or sets the class that match this value The class. Define how broken relations should be handled. Throw an exception when the relation is broken. Throw an exception when the relation is broken. this is the default behaviour Ignore the broken relation and update the FK to null on the next save. Maps a one to one association. public class Post : ActiveRecordBase { ... [BelongsTo("blogid")] public Blog Blog { get { return _blog; } set { _blog = value; } } Please note that the 'blogid' foreign key lies on the 'Post' table. Initializes a new instance of the class. Indicates the name of the column to be used on the association. Usually the name of the foreign key field on the underlying database. Defines the target type of the association. It's usually inferred from the property type. Defines the column used by association (usually a foreign key) Defines the Composite Key columns used by association (aka Natural Keys). Defines the cascading behavior of this association. Defines the outer join behavior of this association. NHibernate has deprecated the outer-join attribute so this property is marked obsolete - it now converts to and from the fetch value. Chooses between outer-join fetching or sequential select fetching. From NHibernate docs: The name of a property of the associated class that is joined to the primary key of this class. If not specified, the primary key of the associated class is used. Set to false to ignore this association when updating entities of this ActiveRecord class. Set to false to ignore this association when inserting entities of this ActiveRecord class. Indicates whether this association allows nulls or not. Indicates whether this association is unique. Gets or sets the way broken relations are handled. The behaviour. From NHibernate documentation: A unique-key attribute can be used to group columns in a single unit key constraint. unique key name Currently, the specified value of the unique-key attribute is not used to name the constraint, only to group the columns in the mapping file. Gets and sets the name of the foreign key constraint generated for an association. Defines the values for the generator for the Collection Id values.w Use Identity column (auto number) Use a sequence Use the HiLo algorithm to get the next value Use a sequence and a HiLo algorithm - better performance on Oracle Use the hex representation of a unique identifier Use the string representation of a unique identifier Generate a Guid for the primary key Note: You should prefer using GuidComb over this value. Generate a Guid in sequence, so it will have better insert performance in the DB. The key value is always assigned. This is a foreign key to another table Used for a collection that requires a collection id. public class Blog : ActiveRecordBase { ... [HasManyAndBelongs/HasMany] [CollectionIDAttribute(CollectionIDAttribute.Native)] public int Id { get { return _id; } set { _id = value; } } Initializes a new instance of the class. The generator. The column. Type of the column. Gets or sets the generator. The generator. Gets or sets the column name The column. Gets or sets the type of the column. The type of the column. Defines that the target property is a composite key for the scope class Gets or sets the unsaved value. The unsaved value. Maps the property to db using a NHibernate's . You should specify the column names and the ICompositeUserType implementor. [CompositeUserType(typeof(DoubleStringType), new string[] {"Product_FirstName", "Product_LastName"})] public string[] Name { get { return name; } set { name = value; } } or [CompositeUserType( typeof(DoubleStringType), new string[]{"Manufacturer_FirstName", "Manufacturer_LastName"}, Length = new int[] {4, 5} )] public string[] ManufacturerName { get { return manufacturerName; } set { manufacturerName = value; } } Initializes a new instance of the class. Initializes a new instance of the class. Type of the ICompositeUserType implmentor. The column names. Gets or sets the type of the ICompositeUserType implementor. The type of the composite. Gets or sets the column names. The column names. Gets or sets the length of the columns. The columns length. Set to false to ignore this property when updating entities of this ActiveRecord class. Set to false to ignore this property when inserting entities of this ActiveRecord class. Defines the values for optimistic locking do not use optimistic locking check the version/timestamp columns check the changed columns check all columns Define the polymorphism options Implicit polymorphism Explicit polymorphism Define the caching options Default value, no caching Read only cache - use for cases where no write are performed. Read write cache Read write cache with looser semantics. Check NHibernate's documentation for the detials. Define outer join options Let NHibernate decide what to do Use outer join Do not use outer join Define the possible fetch option values Let NHibernate decide what to do here Use a JOIN to load the data Use a seperate SELECT statement to load the data Use a seperate SELECT statement to load the data, re-running the original query in a subselect Defines the cascading behaviour of this association. Entities has associations to other objects, this may be an association to a single item () or an association to a collection (, ). At any rate, you are able to tell NHibernate to automatically traverse an entity's associations, and act according to the cascade option. For instance, adding an unsaved entity to a collection with cascade will cause it to be saved along with its parent object, without any need for explicit instructions on our side. No cascading. This is the default. The cascade should be handled manually. Cascade save, update and delete. When the object is saved, updated or deleted, the associations will be checked and the objects found will also be saved, updated or deleted. Cascade save and update. When the object is saved or updated, the associations will be checked and any object that requires will be saved or updated (including saving or updating the associations in many-to-many scenario). Cascade delete. When the object is deleted, all the objects in the association will be deleted as well. Defines the cascading behaviour of this association. Entities has associations to other objects, this may be an association to a single item () or an association to a collection (, ). At any rate, you are able to tell NHibernate to automatically traverse an entity's associations, and act according to the cascade option. For instance, adding an unsaved entity to a collection with cascade will cause it to be saved along with its parent object, without any need for explicit instructions on our side. No cascading. This is the default. The cascade should be handled manually. Cascade save, update and delete. When the object is saved, updated or deleted, the associations will be checked and the objects found will also be saved, updated or deleted. Cascade save and update. When the object is saved or updated, the associations will be checked and any object that requires will be saved or updated (including saving or updating the associations in many-to-many scenario). Cascade delete. When the object is deleted, all the objects in the association will be deleted as well. Cascade save, update and delete, removing orphan children. When an object is saved, updated or deleted, the associations will be checked and all objects found will be saved, updated or deleted as well. In additional to that, when an object is removed from the association and not associated with another object (orphaned), it will also be deleted. Maps a standard column of the table. In the following example, the column is also called 'name', so you don't have to specify. public class Blog : ActiveRecordBase { [Field] string name; Initializes a new instance of the class. Initializes a new instance of the class. The column name. Initializes a new instance of the class. The column name The column type. Gets or sets a value indicating whether the column allows null values true if [not null]; otherwise, false. Gets or sets the length of this column. char(10), etc The length. Gets or sets the column name The column. From NHibernate documentation: A unique-key attribute can be used to group columns in a single unit key constraint. unique key name Currently, the specified value of the unique-key attribute is not used to name the constraint, only to group the columns in the mapping file. From NHibernate documentation: specifies the name of a (multi-column) index index name From NHibernate documentation: overrides the default column type column_type From NHibernate documentation: create an SQL check constraint on either column or table Sql Expression Set to false to ignore this field when updating entities of this ActiveRecord class. Set to false to ignore this field when inserting entities of this ActiveRecord class. Gets or sets a value indicating whether this is unique. true if unique; otherwise, false. Gets or sets the formula used to calculate this field The formula. Gets or sets the type of the column. The type of the column. Maps a many to many association with an association table. public class Company : ActiveRecordBase { ... [HasAndBelongsToMany( typeof(Person), RelationType.Bag, Table="PeopleCompanies", Column="person_id", ColumnKey="company_id" )] public IList People { get { return _people; } set { _people = value; } } } The must specify the key on the association table that points to the primary key of this class. In the example, 'company_id' points to 'Company'. Base class to define common relation information Gets or sets the type of the relation. The type of the relation. Gets or sets the type of the map. The type of the map. Gets or sets the table for this relation The table. Gets or sets the schema for this relation (dbo., etc) The schema name. Gets or sets a value indicating whether this is lazy. true if lazy; otherwise, false. Gets or sets a value indicating whether this is inverse. true if inverse; otherwise, false. Gets or sets the cascade options for this The cascade. Gets or sets the order by clause for this relation. This is a SQL order, not HQL. Gets or sets the where clause for this relation Only used with sets. The value can be unsorted, natural and the name of a class implementing System.Collections.IComparer Only used with maps or lists Only used with maps Use for simple types. Use for simple types. Gets or sets the way broken relations are handled. The behaviour. From NHibernate documentation: Specify a "batch size" for batch fetching of collections. Initializes a new instance of the class. Type of the map. Initializes a new instance of the class. Initializes a new instance of the class. Type of the map. The type. Gets or sets the column that represent the other side on the assoication table The column ref. Gets or sets the composite key columns that represent the other side on the assoication table The composite key column refs. Gets or sets the key column name The column key. Gets or sets the composite key columns names. The composite key column keys. Chooses between outer-join fetching or sequential select fetching. Provides a custom collection type. Maps a one to many association. public class Blog : ActiveRecordBase { ... [HasMany(typeof(Post), RelationType.Bag, ColumnKey="Posts", Table="Posts")] public IList Posts { get { return _posts; } set { _posts = value; } } The key column Cannot exist if compositeKeyColumns has a value The composite columns Cannot exist with keyColumn != null Whether the target type is for dependent objects or not Whether we do outer join fetching for this collection Provides a custom collection type. Initializes a new instance of the class. Initializes a new instance of the class. Type of the map. Initializes a new instance of the class. Type of items in this association The key column. The table. Gets or sets the key column name. The column key. Gets or sets the names of the column in composite key scenarios. The composite key column keys. Whether or not the target type is a dependent object. true = the target type is a dependent object Chooses between outer-join fetching or sequential select fetching. Provides a custom collection type. This attribute allows polymorphic association between classes that doesn't have a common root class. In require two columns that would tell it what is the type of the asssoicated entity, and what is the PK of that entity. This is supplied for advanced sceanrios. For instnace, let assume that you have two classes (that implement a common interface, but have no base classs) called: - Back Account - Credit Card And you have a set of Payment methods, that can be either. You would define the mapping so: [HasManyToAny(typeof(IPayment), "pay_id", "payments_table", typeof(int), "payment_type", "payment_method_id", MetaType = typeof(int), RelationType = RelationType.Set)] typeof(IPayement) - the common interface tha both classes implement, and the type of all the items in the set. "pay_id" - the column that hold the PK of this entity (the FK column) "payments_table" - the table that has the assoication information (in 1:M scenarios - usuaully the same table, in M:N scenarios the link table). typeof(int) - the type of id column "payment_type" - the column used to find out which class is represented by this row. "payment_method_id" - the column that holds the PK of the assoicated class (either CreditCard or BankAccount). MetaType = typeof(int) - the type of the meta column (payment_type) RelationType = RelationType.Set - specify that we use a set here Initializes a new instance of the class. Type of the map. The key colum. The table. Type of the id. The type column. The id column. Gets or sets the type column. The type column. Gets or sets the id column. The id column. Gets or sets the type of the meta column The type of the meta. Gets or sets the type of the id column The type of the id. Used when a constraint requires a hilo algorithm public class Blog : ActiveRecordBase { ... [HasManyAndBelongs/HasMany, CollectionID(CollectionIDAttribute.HiLo), Hilo] public int Id { get { return _id; } set { _id = value; } } Initializes a new instance of the class. Initializes a new instance of the class. The table. The column. The maxlo. Gets or sets the column name The column. Gets or sets the table name The table. Gets or sets the max low value The max lo. This is used to define a named HQL query. It represents the <query> element. [assembly: HqlNamedQuery("allAdultUsers", "from User where user.Age > 21")] Create a new instance The name of the query The query itself This is used to map between a type to a friendly name that can be used in the queries. This attribute is representing an <import/> in the mapping files [Import(typeof(SummaryRow), "summary")] Initializes a new instance of the class. The type. The rename. Gets the type that is being imported The type. Gets or sets the renamed string that will replace the full type name in HQL queries for the specified type. The renamed value. Denotes that a class is the parent class of one or more subclasses using a join Used for joined subclasses. Initializes a new instance of the class. Initializes a new instance of the class. The column. Gets or sets the column name The column. A key property for a composite key Maps a standard column of the table. In the following example, the column is also called 'name', so you don't have to specify. public class Blog : ActiveRecordBase { ... [Property] public int Name { get { return _name; } set { _name = value; } } To map a column name, use [Property("blog_name")] public int Name { get { return _name; } set { _name = value; } } Initializes a new instance of the class. Initializes a new instance of the class. The column. Initializes a new instance of the class. The column. The type. Gets or sets a value indicating whether this property allow null. true if allow null; otherwise, false. Gets or sets the length of the property (for strings - nvarchar(50) ) The length. Gets or sets the column name The column. Set to false to ignore this property when updating entities of this ActiveRecord class. Set to false to ignore this property when inserting entities of this ActiveRecord class. Gets or sets a value indicating whether this is unique. true if unique; otherwise, false. Gets or sets the formula used to calculate this property The formula. Gets or sets the type of the column. The type of the column. From NHibernate documentation: A unique-key attribute can be used to group columns in a single unit key constraint. unique key name Currently, the specified value of the unique-key attribute is not used to name the constraint, only to group the columns in the mapping file. From NHibernate documentation: specifies the name of a (multi-column) index index name From NHibernate documentation: overrides the default column type column_type From NHibernate documentation: create an SQL check constraint on either column or table Sql Expression Set to true if this property overrides a property in a base class Gets or sets the unsaved value. The unsaved value. Maps properties of a child object to columns of the table of a parent class. The following code illustrates the use of a nested PostalAddress class [ActiveRecord("Companies")] public class Company : ActiveRecordBase { private int id; private PostalAddress _address; public Company() { } public Company(string name) { this.name = name; } [PrimaryKey] public int Id { get { return id; } set { id = value; } } [Nested] public PostalAddress Address { get { return _address; } set { _address = value; } } } public class PostalAddress { private String _address; private String _city; private String _state; private String _zipcode; [Property] public String Address { get { return _address; } set { _address = value; } } [Property] public String City { get { return _city; } set { _city = value;} } [Property] public String State { get { return _state; } set { _state = value; } } [Property] public String ZipCode { get { return _zipcode; } set { _zipcode = value; } } } Informs ActiveRecord that the marked property contains nested elements, contained in a separate, reusable class. Informs ActiveRecord that the marked property contains nested elements, contained in a separate, reusable class. A prefix to insert before each column in the nested component Allows one to reference a different type than the property type Set to false to ignore this nested component when updating entities of this ActiveRecord class. Set to false to ignore this nested component when inserting entities of this ActiveRecord class. A prefix to insert before each column in the nested component. Maps a property of a child object to its parent object. The following code illustrates the use of a parent Company class public class PostalAddress { private Company _company; private String _address; private String _city; private String _state; private String _zipcode; [Parent] public Company Parent { get { return _company; } set { _company = value; } } [Property] public String Address { get { return _address; } set { _address = value; } } [Property] public String City { get { return _city; } set { _city = value;} } [Property] public String State { get { return _state; } set { _state = value; } } [Property] public String ZipCode { get { return _zipcode; } set { _zipcode = value; } } } [ActiveRecord("Companies")] public class Company : ActiveRecordBase { private int id; private PostalAddress _address; public Company() { } public Company(string name) { this.name = name; } [PrimaryKey] public int Id { get { return id; } set { id = value; } } [Nested] public PostalAddress Address { get { return _address; } set { _address = value; } } } Informs ActiveRecord that the marked property is the parent of a nested element Associates a foreign table where the current class and the target class share their primary key. The following code exemplifies two classes that maps to two tables sharing the primary key: [ActiveRecord("Employee")] public class Employee : ActiveRecordBase { private int id; private Award award; [PrimaryKey(PrimaryKeyType.Native, "EmployeeID")] public int ID { get { return this.id; } set { this.id = value; } } [OneToOne] public Award Award { get { return this.award; } set { this.award = value; } } } [ActiveRecord("Award")] public class Award : ActiveRecordBase { private Employee employee; private int id; public Award() { } public Award(Employee employee) { this.employee = employee; } [OneToOne] public Employee Employee { get { return this.employee; } set { this.employee = value; } } [PrimaryKey(PrimaryKeyType.Foreign, "EmployeeID")] public int ID { get { return this.id; } set { this.id = value; } } public static Award[] FindAll() { return ((Award[]) (ActiveRecordBase.FindAll(typeof(Award)))); } public static void DeleteAll() { ActiveRecordBase.DeleteAll( typeof(Award) ); } } Employee emp = new Employee(); emp.Name = "john doe"; emp.Save(); Award award = new Award(emp); award.Description = "Invisible employee"; award.Save(); Usually classes that uses the primary key generated elsewhere (foreign) uses the PrimaryKey attribute with the generator type PrimaryKeyType.Foreign Allows one to reference a different type than the property type From NHibernate docs: specifies which operations should be cascaded from the parent object to the associated object. From NHibernate docs: Chooses between outer-join fetching or sequential select fetching. Defaults to From NHibernate docs: The name of a property of the associated class that is joined to the primary key of this class. If not specified, the primary key of the associated class is used. From NHibernate docs: specifies that a foreign key constraint on the primary key of the mapped table references the table of the associated class. This option affects the order in which Save() and Delete() are cascaded (and is also used by the schema export tool). Gets or sets the name of the foreign key constraint generated for an association. NHibernate will only use the ForeignKey name one the inherited class and Constrained = true. Define the possible strategies to set the Primary Key values Use Identity column (auto number) Note: This force an immediate call to the DB when Create() is called Use a sequence Use the HiLo algorithm to get the next value Use a sequence and a HiLo algorithm - better performance on Oracle Use the hex representation of a unique identifier Use the string representation of a unique identifier Generate a Guid for the primary key Note: You should prefer using GuidComb over this value. Generate a Guid in sequence, so it will have better insert performance in the DB. Use an identity or sequence if supported by the database, otherwise, use the HiLo algorithm The primary key value is always assigned. Note: using this you will lose the ability to call Save(), and will need to call Create() or Update() explicitly. This is a foreign key to another table Returns a Int64 constructed from the system time and a counter value. Not safe for use in a clustser Returns a Int64, constructed by counting from the maximum primary key value at startup. Not safe for use in a cluster A custom generator will be provided. See Indicates the property which is the primary key. public class Blog : ActiveRecordBase { ... [PrimaryKey(PrimaryKeyType.Native)] public int Id { get { return _id; } set { _id = value; } } Initializes a new instance of the class. Initializes a new instance of the class. A custom identifier generator (that implements ). Initializes a new instance of the class. The generator. Initializes a new instance of the class. The generator. The PK column. Initializes a new instance of the class. The PK column. Gets or sets the generator. The generator. Gets or sets the column name The column. Gets or sets the unsaved value. The unsaved value. Gets or sets the name of the sequence. The name of the sequence. Gets or sets the type of the column. The type of the column. Gets or sets the length of values in the column The length. Gets or sets the custom generator. The generator must implement The custom generator type. Comma separated value of parameters to the generator Set to true if this primary key overrides a primary key in a base class Define the various access strategies NHibernate will use to set/get the value for this property. Use the property get/set methods to get and set the value of this property [Property(Access=PropertyAccess.Property)] public string UserName { get {... } set { ... } } Use the field to get/set the value. (Only valid when specify on a field). [Property(Access=PropertyAccess.Field)] public string UserName; // notice this is a field, not property. Use the field that is the backing store for this property to get/set the value of this property. The field is using the same name as the property, in camel case. string userName;//this will be use to get or set the value [Property(Access=PropertyAccess.FieldCamelCase)] public string UserName { get {... } set { ... } } Use the field that is the backing store for this property to get/set the value of this property. The field is using the same name as the property, in camel case and with an initial underscore string _userName;//this will be use to get or set the value [Property(Access=PropertyAccess.FieldCamelcaseUnderscore)] public string UserName { get {... } set { ... } } Use the field that is the backing store for this property to get/set the value of this property. The field is using the same name as the property, in pascal case and with an initial m and then underscore. m_Name for the property Name. string m_UserName;//this will be use to get or set the value [Property(Access=PropertyAccess.FieldPascalcaseMUnderscore)] public string UserName { get {... } set { ... } } Use the field that is the backing store for this property to get/set the value of this property. The field is using the same name as the property, in all lower case and with inital underscore string _username;//this will be use to get or set the value [Property(Access=PropertyAccess.FieldLowercaseUnderscore)] public string UserName { get {... } set { ... } } Use the property' getter to get the value, and use the field with the same name and in camel case in order to set it. string _userName;//this will be use to set the value [Property(Access=PropertyAccess.NosetterCamelcase)] public string UserName { get {... } set { ... } } // this will be used just to get the value Use the property' getter to get the value, and use the field with the same name and in camel case with initial "_" in order to set it. string _userName;//this will be use to set the value [Property(Access=PropertyAccess.NosetterCamelcaseUnderscore)] public string UserName { get {... } set { ... } } // this will be used just to get the value Use the property' getter to get the value, and use the field with the same name and in pascal case with initial "_" in order to set it. string _UserName;//this will be use to set the value [Property(Access=PropertyAccess.NosetterPascalcaseUnderscore)] public string UserName { get {... } set { ... } } // this will be used just to get the value Use the property' getter to get the value, and use the field with the same name and in pascal case with initial "m_" in order to set it. string m_UserName;//this will be use to set the value [Property(Access=PropertyAccess.NosetterPascalcaseMUndersc)] public string UserName { get {... } set { ... } } // this will be used just to get the value Use the property' getter to get the value, and use the field with the same name and in lower case with initial "_" in order to set it. string _username;//this will be use to set the value [Property(Access=PropertyAccess.NosetterLowercaseUnderscore)] public string UserName { get {... } set { ... } } // this will be used just to get the value Use the property' getter to get the value, and use the field with the same name and in lower case in order to set it. string username;//this will be use to set the value [Property(Access=PropertyAccess.NosetterLowercase)] public string UserName { get {... } set { ... } } // this will be used just to get the value Utility class to help convert between values and NHiberante's access strategies. Convert to its NHibernate string Abstract base class for custom attributes that can generate XML and return it directly. This allows to customize the generate the XML passed to NHibernate in a flexible way. Get the mapping xml to add to NHibernate's configuration. Note that we allow to return more than a single mapping, each string is treated as a seperated document. Define the relation type for a relation. Let Active Record guess what is the type of the relation. An bag of items (allow duplicates) A set of unique items A bag of items with id Map of key/value pairs (IDictionary) A list of items - position in the list has meaning Specify that this property is used for timestamping this entity Initializes a new instance of the class. Initializes a new instance of the class. The column name Gets or sets the column name The column. This attribute is used to specify that a property is the versioning property of the class Initializes a new instance of the class. Initializes a new instance of the class. The column. Gets or sets the column name The column. Gets or sets the type of the column (should be an integer of some type) The type. Gets or sets the unsaved value for this column The unsaved value. Reads the configuration from a entry 'activerecord' in the xml associated with the AppDomain Source of configuration based on Xml source like files, streams or readers. Usefull for test cases. Abstracts the source of configuration for the framework. Implementors should return an instance Implementors should return the type that implements the interface Implementors should return the type that implements the interface Implementors should return the type that implements the interface NHibernate.Cfg.INamingStrategy Gets a value indicating whether this produce debug information true if debug; otherwise, false. Gets a value indicating whether the entities should be lazy by default. true if entities should be lazy by default; otherwise, false. Gets a value indicating whether table names are assumed plural by default. true if table names should be pluralized by default; otherwise, false. Gets or sets a value indicating whether the models should be verified against the db schema on Initialisation. true if models should be verified; otherwise, false. Initializes a new instance of the class. Return an for the specified type. Builds a InPlaceConfigurationSource set up to access a MS SQL server database using integrated security. The server. The initial catalog. Builds a InPlaceConfigurationSource set up to access a MS SQL server database using the specified username and password. The server. The initial catalog. The username. The password. Builds an InPlaceConfiguratioSource for the specified database. The database. The connection string. Adds the specified type with the properties The type. The properties. Adds the specified type with configuration The type. The config. Sets the type of the thread info. if we run in a web context or not Type of the custom implementation Sets the type of the session factory holder. Custom implementation Sets the type of the naming strategy. Custom implementation type name Sets the debug flag. if set to true Active Record will produce debug information. Set whatever entities are lazy by default or not. Sets the debug flag. if set to true Active Record will verify the models against the db schema on startup. Sets the pluralizeTableNames flag. if set to true Active Record will pluralize inferred table names. Processes the configuration applying any substitutions. The configuration Return a type that implements the interface Return a type that implements the interface Return a type that implements the interface NHibernate.Cfg.INamingStrategy Gets a value indicating whether this produce debug information true if debug; otherwise, false. Gets a value indicating whether the entities should be lazy by default. true if entities should be lazy by default; otherwise, false. Gets a value indicating whether table names are assumed plural by default. true if table names should be pluralized by default; otherwise, false. Gets or Sets a value indicating whether the models should be verified against the db schema on Initialisation. true if models should be verified; otherwise, false. Sets a value indicating whether this instance is running in web app. true if this instance is running in web app; otherwise, false. Initializes a new instance of the class. Initializes a new instance of the class. Name of the XML file. Initializes a new instance of the class. The stream. Initializes a new instance of the class. The reader. Populate this instance with values from the given XML node Builds the configuration properties. The node. Creates a configuration section handler. Configuration context object. The created section handler object. Gets the sole instance. The instance. Enum for database types support for configuration construction. Not to be confused by databases supported by ActiveRecord Microsoft SQL Server 2005 Microsoft SQL Server 2000 This model of a full Active Record persistent class. For implementing the Visitor pattern. All the nodes in the model implements this interface Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. The mapping between a type and a model Whatever Active Record will generate debug information or not Whatever types that does not explicitly state that they are lazy should be lazy. Whether the default inferred table name is plural Initializes a new instance of the class. The type. Used internally register an association between a type and its model Gets the for a given ActiveRecord class. Gets an array containing the for every registered ActiveRecord class. Get the base type is the object is lazy Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets or sets the parent model The parent. Gets the type for this model The type. Gets or sets a value indicating whether this instance is joined sub class base. true if this instance is joined sub class base; otherwise, false. Gets or sets a value indicating whether this instance is discriminator base. true if this instance is discriminator base; otherwise, false. Gets or sets a value indicating whether this instance is discriminator sub class. true if this instance is discriminator sub class; otherwise, false. Gets or sets a value indicating whether this instance is joined sub class. true if this instance is joined sub class; otherwise, false. Gets or sets a value indicating whether this instance is nested type. true if this instance is nested type; otherwise, false. Gets or sets the parent nested. The parent nested. Gets or sets a value indicating whether this instance is nested type. true if this instance is nested type; otherwise, false. Gets or sets the active record attribute The active record att. Used only by joined subclasses Gets or sets the timestamp model The timestamp. Gets or sets the version model The version. Gets all the imports The imports. Gets all the properties The properties. Gets all the fields The fields. If the object is a component, will return the objects declared parent property. There should only be one, but implemented as a list Gets the list of [has many to any] models The has many to any. Gets the list of [any] model The anys. Gets the list of the derived classes The classes. Gets the list of derived joined classes. The joined classes. Gets the list of components. The components. Gets the list of [belongs to] models The belongs to. Gets the list of [has many] models The has many. Gets the list of [has and belongs to many] models The has and belongs to many. Gets the list of [one to one] models The one to ones. Gets the list of [collection id] models The collection I ds. For unique Primary keys For Composite Primary keys Gets the list of [hilo] models The hilos. Gets the list of properties not mapped . The not mapped properties. Gets the validators. The validators. Gets a value indicating whether to use auto import true if should use auto import; otherwise, false. Gets the composite user types properties. The type of the composite user. Gets the extended properties. Used to store/retrieve information collected by model builder extensions. The extended properties. Gets the property dictionary. Used to provide fast access to a based on the property name. The property dictionary. Gets the belongs to dictionary. Used to provide fast access to a based on the property name. The belongs to dictionary. Gets the has many to any dictionary. Used to provide fast access to a based on the property name. The has many to any dictionary. Gets the has many dictionary. Used to provide fast access to a based on the property name. The has many dictionary. Gets the has and belongs to many dictionary. Used to provide fast access to a based on the property name. The has and belongs to many dictionary. Model for [Any] association, a polymorphic association without common base class Initializes a new instance of the class. The prop. Any att. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the property. The property. Gets the [Any] attribute Any att. Gets or sets the meta values. The meta values. Model for BelongTo - A many to one assoication between persistent entities. Initializes a new instance of the class. The prop info. The belongs to att. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the property. The property. Gets the belongs to attribute The belongs to att. This is used in IdBag scenario to specify to collection id. Initializes a new instance of the class. The prop info. The coll att. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the property. The property. Gets the collection ID att. The collection ID att. Gets or sets the hilo. The hilo. Model for representing a composite key Initializes a new instance of the class. The prop info. The pk att. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the property. The property. Gets the composite key att. The composite key att. Model for representing a Composite User type map. Initializes a new instance of the class. The property marked with the attribute. The metadata attribute. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the property marked with the attribute. The property. Gets the attribute instance. The attribute. This model is used to represent a dependent object value type (<composite-element/> - in NHibernate talk). Initializes a new instance of the class. The prop info. The nested att. The nested model. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the model. The model. Gets the has many attribute The has many att. Model for a persitent property that uses a field to get/set the values. Initializes a new instance of the class. The field. The att. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the field. The field. Gets the field attribute The field att. Model to HasAndBelongsToMany, which is used to model a many to many assoication. Initializes a new instance of the class. The prop info. The has many att. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the property. The property. Gets the has many attribute The has many att. Gets or sets the collection ID. The collection ID. Model to represent a HasMany ( one to many ) association Initializes a new instance of the class. The prop info. The has many att. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the property. The property. Gets the has many attribute The has many att. Gets/Sets the the dependent object model The dependent object model. This model represent a <many-to-any/> polymorphic association Initializes a new instance of the class. The prop. The has many to any att. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the property. The property. Gets the has many to any attribute The has many to any att. Gets the configuration. The configuration. Gets or sets the meta values. The meta values. I need this class to pass special configuration for the many-to-any Initializes a new instance of the class. The parent. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets or sets the parent model The parent. Model for HiLo algorithm used to generate primary key values Initializes a new instance of the class. The prop info. The hilo att. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the property. The property. Gets the hilo attribute The hilo att. Model for importing classes so HQL queries can use them more easily. Initializes a new instance of the class. The att. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the import attribute The import att. Model for a joined key property in a joined subclass Initializes a new instance of the class. The prop info. The att. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the property. The property. Gets the joined key attribute The joined key att. This model is used to represent a nested value type (<component/> - in NHibernate talk). Initializes a new instance of the class. The prop info. The nested att. The nested model. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the model. The model. Gets the property. The property. Gets the nested attribute The nested att. This model is used to represent a nested value type's parent (<parent /> - in NHibernate talk). Initializes a new instance of the class. The prop info. The parent att. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the property. The property. Gets the nested attribute The nested att. Model One To One assoication Initializes a new instance of the class. The prop info. The att. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the property. The property. Gets the one to one attribute The one to one att. Model for a Primary Key Initializes a new instance of the class. The prop info. The pk att. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the property. The property. Gets the primary key attribute The primary key att. Model for a simple persistent property Initializes a new instance of the class. Initializes a new instance of the class. The prop. The att. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the property. The property. Gets the property attribute The property att. Model for [Timestamp] properties Initializes a new instance of the class. The prop. The att. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the property. The property. Gets the timestamp attribute The timestamp att. Model for version property on an entity Initializes a new instance of the class. The prop. The att. Accepts the specified visitor and call the relevant IVisitor.Visit***() method The visitor. Gets the property. The property. Gets the version attribute The version att. Base class for visitors that needs to traverse the entire Active Record Model For implementign the visitor pattern. Visits the top level of the model. The model. Visits the primary key. The model. Visits the composite primary key. The model. Visits the has many to any association The model. Visits any. The model. Visits the property. The model. Visits the field. The model. Visits the component parent reference The model. Visits the version. The model. Visits the timestamp. The model. Visits the key. The model. Visits the belongs to association The model. Visits the has many association The model. Visits the one to one association The model. Visits the has and belongs to many association The model. Visits the hilo strategy The model. Visits the nested (component) model The model. Visits the collection ID. The model. Visits the has many to any configuration The has many to any config model. Visits the import statement The model. Visits the dependent object model The model. Visits the custom composite user type. The model. Visits the node. The visitable. Visits the nodes. The nodes. Visits the model. The model. Visits the primary key. The model. Visits the composite primary key. The model. Visits the has many to any. The model. Visits the property. The model. Visits the field. The model. Visits the component parent The model. Visits any. The model. Visits the version. The model. Visits the timestamp. The model. Visits the key. The model. Visits the belongs to. The model. Visits the has many. The model. Visits the one to one. The model. Visits the has and belongs to many. The model. Visits the hilo. The model. Visits the nested. The model. Visits the collection ID. The model. Visits the has many to any config. The has many to any config model. Visits the import. The model. Visits the Dependent Object à The model Visits the custom composite user type. The model. Guesses the type of the other end. The type. Type of the property. Connects with their parents Initializes a new instance of the class. The ar collection. Visits the model. The model. Visits the nested. The model. Visits the collection ID. The model. Visits the hilo model The model. Traverse the tree checking the semantics of the relation and association. The goal is to raise clear exceptions with tips of how to fix any error. It also tries to infer as much information from the class / attribute model as possible so it can complete the missing information without the user needing to specify it. Initializes a new instance of the class. The ar collection. Visits the model. Check that the model: - Define only a discriminator or a join subclass, not both - Doesn't specify version/timestamp property on a joined subclass / discriminator subclass - Validate that the custom entity persister implements IEntityPersister - Validate the joined subclasses has a [JoinedKey] to map back to the parent table - Validate that the class has a PK The model. Visits the primary key. Infer column name and the reverse property if using [OneToOne] The model. Visits the composite primary key. Validate that the composite key type is implementing GetHashCode() and Equals(), is mark serializable. Validate that the compose key is compose of two or more columns The model. Visits the property. Infer column name and whatever this propery can be null or not Also catch common mistake of try to use [Property] on an entity, instead of [BelongsTo] The model. Visits the field. Infer column name and nullablity The model. Visits the key. Infer column name The model. Visits the version. Infer column name The model. Visits the timestamp. Infer column name The model. Visits the belongs to. Infer column name and type Verify that the property is virtual if the class was marked lazy. The model. Visit the has many to any The model. Visits any. The model. Visits the has many. Guess the type of the relation, if not specified explicitly Verify that the assoication is valid on [HasMany] Validate that required information is specified Infer the other side of the assoication and grab require data from it The model. Visits the has and belongs to many. Verify that a link table was specified Verify that a key was specified and that it is valid Verify that required information was specified The model. Visits the one to one. Infer the type on the other side The model. Visits the nested model Infer the column name and applies and column prefixes specified The model. Visits the custom composite user type. Apply any column prefixes specified The model. Gets the index type of a mapped dictionary. Type of the property. The index type of a map element Gets the index type of a mapped dictionary. Type of the property. The index type of a map element Traverse the tree emitting proper xml configuration Resets this instance. Creates the XML. The model. Visits the model. The model. Visits the primary key. The model. Visits the composite primary key. The model. Visits the import. The model. Visits the property. The model. Visits the field. The model. Visits the parent The reference model. Visits any. The model. Visits the has many to any. The model. Visits the has many to any config. The model. Visits the version. The model. Visits the timestamp. The model. Visits the key. The model. Visits the one to one. The model. Visits the belongs to. The model. Visits the has many. The model. Visits the has and belongs to many. The model. Visits the nested. The model. Visits the dependent object. The model Visits the collection ID. The model. Visits the hilo. The model. Visits the custom composite user type. The model. Create a valid name from a type, without including all the version and public key information Gets the XML. The XML. Bulids an from a type and does some inital validation. Creates a from the specified type. The type. Sets the extension. The extension. Populates the model from tye type The model. The type. Remove the generic part from the type name. Gets the models. The models. Gets the validator registry used to create the validators Map System.Type to their ActiveRecordModel Adds the specified model. The model. Determines whether the collection contains the specified type. The type. true if the collection contains the specified type; otherwise, false. Returns an enumerator that iterates through a collection. An object that can be used to iterate through the collection. Gets the with the specified type. Generate xml from assembly level attributes. This is useful if we need to have type-less configuration, such as imports, named queries, etc. Create a new instnace Reset this generator and prepare to generate xml from new assembly. Generate XML from assembly attributes. If it can't find relevant attributes, returns null. Gives a chance to external frameworks to plug into the AR model builder process. Particularly useful to inspect attributes and conventions outside the AR domain. Gives implementors a chance to process the class. The type. The model. Gives implementors a chance to process the property. The property info reflection object. The model. Gives implementors a chance to process the field. The field info reflection object. The model. Gives implementors a chance to process the BelongsTo. The property info reflection object. The belongs to model. The model. Gives implementors a chance to process the HasMany. The property info reflection object. The has many model. The model. Gives implementors a chance to process the HasManyToAny. The property info reflection object. The has many model. The model. Gives implementors a chance to process the HasAndBelongsToMany. The property info reflection object. The has and belong many model. The model. The Inflector class transforms words from one form to another. For example, from singular to plural. Return the plural of a word. The singular form The plural form of Return the singular of a word. The plural form The singular form of Capitalizes a word. The word to be capitalized. capitalized. Dispatches the extension invocations to the inner extension list. Initializes a new instance of the class. The extensions. Dispatches the call to the extensions. The type. The model. Dispatches the call to the extensions. The property info reflection object. The model. Dispatches the call to the extensions. The field info reflection object. The model. Dispatches the call to the extensions. The property info reflection object. The belongs to model. The model. Dispatches the call to the extensions. The property info reflection object. The has many model. The model. Dispatches the call to the extensions. The property info reflection object. The has many model. The model. Dispatches the call to the extensions. The property info reflection object. The has and belong many model. The model. Any object which intent to change a NHibernate query must implement this interface. Applies this modifier to the query. The query Represents a query parameter. Initializes a new instance of the class. The name. The value. Initializes a new instance of the class. The name. The value. The type. Initializes a new instance of the class. The position. The value. Initializes a new instance of the class. The position. The value. The type. Initializes a new instance of the class. The name. The value. The type. Initializes a new instance of the class. The name. The value. It is important to keep this constructor as is, to avoid confusion with the overload. It is important to keep this constructor as is, to avoid confusion with the overload. Add this parameter to the . The query Is there a cleaner way to do this, without reflection or complex hierarchies? The position of the positional parameter, or -1 if this is a named parameter. The name of the named parameter, or null if this is a positional parameter. The parameter value. The NHibernate type. Limits a query to the specified results. Initializes a new instance of the class. The first result. The max results. Initializes a new instance of the class. The max results. Applies this modifier to the query. The query Gets the first result. The first result. Gets the max results. The max results. Defines a query result transformation. See for more information. Initializes a new instance of the class. The result transformer. Applies this modifier to the query. The query Gets the . Represents a SQL query join definition. See for more information. Initializes a new instance of the class. The association path. The association alias. Applies this modifier to the query. s The query Gets the path of the assocation Gets the alias for the association Represents a SQL query return definition. See for more information. Initializes a new instance of the class. Type of the return object. Gets the alias for the object Applies this modifier to the query. The query Gets the type of the returned object The type of the return. Gets the alias for the object The return alias. Represents a SQL query scalar definition. See for more information. Initializes a new instance of the class. The scalar type. The column alias. Applies this modifier to the query. s The query Gets the scalar type Gets the column alias for the scalar Base class for all ActiveRecord queries. Represents an ActiveRecord Query. Executes the specified query and return the results The session to execute the query in. Enumerates over the result of the query. Note: Only use if you expect most of your values to already exist in the second level cache! Gets the target type of this query list of modifiers for the query Initializes a new instance of the class. The type. Executes the specified query and return the results The session to execute the query in. Enumerates over the result of the query. Note: Only use if you expect most of your values to already exist in the second level cache! Simply creates the query and then call its method. The NHibernate's Simply creates the query and then call its method. Note: Only use when you expect most of the results to be in the second level cache The NHibernate's Add this query to a multiquery an ISession shared by all queries in the multiquery the IMultiQuery that will receive the newly created query Creates the instance. Just a default clone implementation... Adds a query modifier, to be applied with . The modifier Applies the modifiers added with . The query in which to apply the modifiers This method is not called automatically by , but is called from . Converts the results stored in an to an strongly-typed array. The type of the new array The source list If true, only distinct results will be inserted in the array The strongly-typed array Converts the results stored in an to an strongly-typed array. The type of the new array The source list If the HQL clause selects more than one field, or a join is performed without using fetch join, the contents of the result list will be of type object[]. Specify which index in this array should be used to compose the new result array. Use -1 to ignore this parameter. If true, only distinct results will be inserted in the array The strongly-typed array Gets the internal list of modifiers used by the specified query. NOT INTENTED FOR NORMAL USE. Gets the target type of this query Use the specified logger to output diagnostic messages. Criteria Query Note: This query can not be included in a MultiQuery. the problem is that NHibernate does not have a real CriteriaQuery class Base class for all HQL or SQL-based queries. Initializes a new instance of the class. Type of the target. The query. Initializes a new instance of the class. Type of the target. The query. The positional parameters. Initializes a new instance of the class. Type of the target. The query language. The query. Initializes a new instance of the class. Type of the target. The query language. The query. The positional parameters. Sets a parameter with the given name. Name of the parameter. The value. Sets a parameter with the given name and type Name of the parameter. The value. The type. Sets a parameter with the given name with a list of values Name of the parameter. The list. Sets a parameter with the given name with a list of values and type Name of the parameter. The list. The type. Sets the query range (paging) The first result. The maximum number of results returned (page size) Sets the query range (maximum number of items returned) The maximum number of results. Adds a SQL query return definition. See for more information. Adds a SQL query join definition. See for more information. Adds a SQL query scalar definition. See for more information. Adds a query result transformer. See for more information. Creates the instance. The query text. Initializes a new instance of the class. The target type. Criteria applied to the query Initializes a new instance of the class. The target type. Criteria applied to the query Executes the query. The NHibernate's ArrayList as an object wrapper for an IMultiQuery that executes a collection of queries. Initializes a new instance of the class. the root type for all of the queries that will be included in the IMultiQuery Initializes a new instance of the class. the root type for all of the queries that will be included in the IMultiQuery an array of IActiveRecordQuery Add an IActiveRecordQuery to our IActiveRecordQuery to be added to the MultiQuery Executes the specified query and return the results The session to execute the query in. an array of results, one for each query added (Not Implemented!) Enumerates over the result of the query. Note: Only use if you expect most of your values to already exist in the second level cache! Gets the target type of this query Query the database for a count (using COUNT(*) ) of all the entites of the specified type. Optionally using a where clause; Note: If Criteria are used, this query can not be included in a MultiQuery. Initializes a new instance of the class. The target type. The filter. The parameters. Initializes a new instance of the class. The target type. Initializes a new instance of the class. The target type. Criteria applied to the query Initializes a new instance of the class. The target type. Criteria applied to the query Executes the query. The NHibernate's System.Int32 as object defines the possible query langauges Hibernate Query Language Structured Query Language Represents an ActiveRecord Query. The resulting object type Executes the query using specified session. The session. Performs a projected selection from an entity, lifting only the required fields. Similar to SELECT Id,Name FROM MyTable instead of selecting everything. It is possible to combine this with grouping. The active record entity type The result value to use: object[] means returning as is /// proj = new ProjectionQuery(Projections.Property("Title"), Projections.Property("Id")); ICollection posts = proj.Execute(); foreach(PostTitleAndId titleAndId in posts) { //push to site... } ]]> Create a new with the given projections. At least one projections must be given The projections to use in the query Create a new with the given projections. At least one projections must be given. The DetachedCriteria is mostly used for filtering, although it is possible to use it for ordering, limiting the result set, etc. Note: Do not call SetProjection() on the detached criteria, since that is overwritten. Criteria to select by The order by which to get the result The projections Create a new with the given projections. At least one projections must be given. The DetachedCriteria is mostly used for filtering, although it is possible to use it for ordering, limiting the result set, etc. Note: Do not call SetProjection() on the detached criteria, since that is overwritten. Criteria to select by The order by which to get the result The projections Create a new with the given projections. At least one projections must be given. The results will be loaded according to the order specified Create a new with the given projections. At least one projections must be given. The DetachedCriteria is mostly used for filtering, although it is possible to use it for ordering, limiting the result set, etc. Note: Do not call SetProjection() on the detached criteria, since that is overwritten. Sets the query range. The first row to return. The max number of rows to return. The instance Executes the specified query and return the results The session to execute the query in. IList<TResultItem> cast to object because of interface Enumerates over the result of the query. Note: Only use if you expect most of your values to already exist in the second level cache! Executes the specified query and return the results the result of the query Gets the target type of this query This is used to convert the resulting tuples into strongly typed objects. Convert the tuples into a strongly typed object Default implemenation of ProjectionQuery that returns an Untyped object array tuples Create a new with the given projections. At least one projections must be given The projections to use in the query Create a new with the given projections. At least one projections must be given. The DetachedCriteria is mostly used for filtering, although it is possible to use it for ordering, limiting the result set, etc. Note: Do not call SetProjection() on the detached criteria, since that is overwritten. Criteria to select by The order by which to get the result The projections Create a new with the given projections. At least one projections must be given. The DetachedCriteria is mostly used for filtering, although it is possible to use it for ordering, limiting the result set, etc. Note: Do not call SetProjection() on the detached criteria, since that is overwritten. Criteria to select by The order by which to get the result The projections Create a new with the given projections. At least one projections must be given. The results will be loaded according to the order specified Create a new with the given projections. At least one projections must be given. The DetachedCriteria is mostly used for filtering, although it is possible to use it for ordering, limiting the result set, etc. Note: Do not call SetProjection() on the detached criteria, since that is overwritten. Perform a scalar projection ( aggeregate ) type of query: avg, max, count(*), etc. The type of the entity we are querying The type of the scalar from this query ScalarProjectionQuery<Blog, int> proj = new ScalarProjectionQuery<Blog, int>(Projections.RowCount()); int rowCount = proj.Execute(); Initializes a new instance of the class. The projection. The criterions. Initializes a new instance of the class. The projection. The detached criteria. Executes the specified query and return the results The session to execute the query in. the result of the query Enumerates over the result of the query. Always returns a single result Executes the specified query and return the results The session to execute the query in. the result of the query Executes the specified query and return the results the result of the query Gets the target type of this query Query that return a single result Initializes a new instance of the class. Type of the target. The query. The positional parameters. Initializes a new instance of the class. Type of the target. The query. Initializes a new instance of the class. Type of the target. The query language. The query. The positional parameters. Initializes a new instance of the class. Type of the target. The query language. The query. Executes the query and returns its scalar result. The NHibernate's The query's scalar result Creates a single-position object array containing the query's scalar result. The NHibernate's An object[1] containing the query's scalar result. Represents a query that can result in a value of the type . The resulting object type If the query result is null, and is a value type, the default value for that type will be returned. Creates a new ScalarQuery for the giving , using the specified positional and the target ActiveRecord type specified in . The target ActiveRecord type The query The positional positionalParameters Creates a new ScalarQuery for the giving and the target ActiveRecord type specified in . The target ActiveRecord type The query Creates a new ScalarQuery for the giving , using the specified positional and the target ActiveRecord type specified in . The target ActiveRecord type The language of the query The query The positional positionalParameters Creates a new ScalarQuery for the giving and the target ActiveRecord type specified in . The target ActiveRecord type The language of the query The query Executes the query and gets the result. Simple query. Creates a new SimpleQuery. Creates a new SimpleQuery. Creates a new SimpleQuery. Creates a new SimpleQuery. Executes the query and converts the results into a strongly-typed array of . The NHibernate's Represents a query that can result in an array of objects of the type . The resulting object type Creates a new SimpleQuery for the giving , using the specified positional . The target ActiveRecord type is . The query The positional parameters Creates a new SimpleQuery for the giving , using the specified positional . The target ActiveRecord type is . The query The query language The positional parameters Creates a new SimpleQuery for the giving , using the specified positional and the target ActiveRecord type specified in . The target ActiveRecord type The query The positional parameters Creates a new SimpleQuery for the giving , using the specified positional and the target ActiveRecord type specified in . The target ActiveRecord type The query language The query The positional parameters Executes the query and gets the results. Enumerates the query results. Better suited for queries which might return large results. It might not look obvious at first, but will call our , which will call our , which will convert the NHibernate's result returned by into a generic . So, all we need to do is to cast it back to . Simply creates the query and then call its method. Note: Only use when you expect most of the results to be in the second level cache The NHibernate's Needed to avoid CS1911. Executes the query and converts the results into a strongly-typed array of . The NHibernate's Abstract implementation Contract for implementation of scopes. A scope can implement a logic that affects AR for the scope lifetime. Session cache and transaction are the best examples, but you can create new scopes adding new semantics. The methods on this interface are mostly invoked by the implementation Flushes the sessions that this scope is maintaining Evicts the specified instance from the session cache. The instance. This method is invoked when no session was available at and the just created one. So it registers the session created within this scope using a key. The scope implementation shouldn't make any assumption on what the key actually is as we reserve the right to change it an object instance An instance of ISession This method is invoked when the instance needs a session instance. Instead of creating one it interrogates the active scope for one. The scope implementation must check if it has a session registered for the given key. an object instance true if the key exists within this scope instance This method should return the session instance associated with the key. an object instance the session instance or null if none was found If the returned true then this method is invoked to allow the scope to create a properly configured session From where to open the session the NHibernate interceptor the newly created session This method will be called if a session action fails. The scope may then decide to use an different approach to flush/dispose it. The session that failed Returns the defined for this scope Returns the defined for this scope Implementors should return true if they want that their scope implementation be in charge of creating the session Map between a key to its session Initializes a new instance of the class. The flush action. The type. Flushes the sessions that this scope is maintaining Evicts the specified instance from the session cache. The instance. This method is invoked when the instance needs a session instance. Instead of creating one it interrogates the active scope for one. The scope implementation must check if it has a session registered for the given key. an object instance true if the key exists within this scope instance This method is invoked when no session was available at and the just created one. So it registers the session created within this scope using a key. The scope implementation shouldn't make any assumption on what the key actually is as we reserve the right to change it an object instance An instance of ISession This method should return the session instance associated with the key. an object instance the session instance or null if none was found If the returned true then this method is invoked to allow the scope to create a properly configured session From where to open the session the NHibernate interceptor the newly created session Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. Initializes the specified session. The session. Performs the disposal. The sessions. Performs the disposal. The sessions. if set to true [flush]. if set to true [close]. Discards the sessions. The sessions. Marks the session as failed The session Sets the flush mode. The session. Gets the sessions. Removes the session. The session. Returns the defined for this scope Returns the defined for this scope Implementors should return true if they want that their scope implementation be in charge of creating the session Base implementation. It's up to derived classes to provide a correct implementation of CurrentStack only Implementation of this interface provide a way to get the current scope. This is used by the rest of the Active Record framework to grab a scope (and from it a session). Gets the registered scope. Registers the scope. The scope. Unregister the scope. The scope. Gets the current stack. The current stack. Gets a value indicating whether this instance has initialized scope. true if this instance has initialized scope; otherwise, false. Registers the scope. The scope. Gets the registered scope. Unregister the scope. The scope. Gets the current stack. The current stack. Gets a value indicating whether this instance has initialized scope. true if this instance has initialized scope; otherwise, false. Still very experimental and it's not bullet proof for all situations Initializes a new instance of the class. The connection. Initializes a new instance of the class. The connection. The flush action. This method is invoked when no session was available at and the just created one. So it registers the session created within this scope using a key. The scope implementation shouldn't make any assumption on what the key actually is as we reserve the right to change it an object instance An instance of ISession This method is invoked when the instance needs a session instance. Instead of creating one it interrogates the active scope for one. The scope implementation must check if it has a session registered for the given key. an object instance true if the key exists within this scope instance This method should return the session instance associated with the key. an object instance the session instance or null if none was found Performs the disposal. The sessions. If the returned true then this method is invoked to allow the scope to create a properly configured session From where to open the session the NHibernate interceptor the newly created session This is called when a session has a failure the session We want to be in charge of creating the session Pendent Original behavior. Changes are persisted at the end or before some queries. Flush need to be controlled manually. Best choice for readonly operations This implementation will first try to get the current scope from the current request, and if not found, will use a thread lcoal scope. This is used for scenarios where most of the you need per request scope, but you also does some work outside a request (in a thread pool thread, for instnace). Implemenation of this interface provides that is compatible with Session Per Request pattern. Gets the current stack. The current stack. Define session scope types Undefined type of session scope. This value probably should never exist Simple - non transactional session scope Transactional session scope Custom implementation of session scope. This exception is raised when something went wrong with the scope management. Initializes a new instance of the class. The message. Initializes a new instance of the class. The that holds the serialized object data about the exception being thrown. The that contains contextual information about the source or destination. The class name is null or is zero (0). The info parameter is null. Implementation of to augment performance by caching the session, thus avoiding too much opens/flushes/closes. Is set to true if the session went stalled due to an error (usually db operations) Initializes a new instance of the class. The flush action. The type. Initializes a new instance of the class. Initializes a new instance of the class. The flush action. Deprecated! Disposes the specified discard changes. Please use new SessionScope(FlushAction.Never) if set to true [discard changes]. Performs the disposal. The sessions. This is called when an action on a session fails The session Gets or sets a flag indicating whether this instance has session error. true if this instance has session error; otherwise, false. Gets the current scope The current. Class to allow scopes to reach the implementation of . Also implements the delegating the calls to the scope set. Gets the registered scope. Registers the scope. The scope. Unregister the scope. The scope. Gets the single instance. The instance. Gets or sets the scope info. The scope info. Gets the current stack. The current stack. Gets a value indicating whether this instance has initialized scope. true if this instance has initialized scope; otherwise, false. This implementation will first get the current scope from the current thread. Do NOT use on web scenario (web applications or web services). Gets the current stack. The current stack. Defines the transaction scope behavior Inherits a transaction previously create on the current context. Always create an isolated transaction context. Governs the behavior on dispose if neither nor was called Should commit the transaction, unless was called before the disposing the scope (this is the default behavior) Should rollback the transaction, unless was called before the disposing the scope Implementation of to provide transaction semantics Initializes a new instance of the class. Initializes a new instance of the class. The on dispose behavior. Initializes a new instance of the class. Whatever to create a new transaction or inherits an existing one Initializes a new instance of the class. Whatever to create a new transaction or inherits an existing one The on dispose behavior. Initializes a new instance of the class. Whatever to create a new transaction or inherits an existing one The transaction isolation level. The on dispose behavior. Votes to roll back the transaction Votes to commit the transaction This method is invoked when the instance needs a session instance. Instead of creating one it interrogates the active scope for one. The scope implementation must check if it has a session registered for the given key. an object instance true if the key exists within this scope instance This method is invoked when no session was available at and the just created one. So it registers the session created within this scope using a key. The scope implementation shouldn't make any assumption on what the key actually is as we reserve the right to change it an object instance An instance of ISession This method should return the session instance associated with the key. an object instance the session instance or null if none was found Flushes the sessions that this scope or its parents are maintaining Ensures that a transaction exist, creating one if neccecary The session. Initializes the current transaction scope using the session The session. Dispose of this scope The sessions. This is called when a session has a failure the session Discards the sessions. The sessions. Raises the on completed event This event is raised when a transaction is completed This implementation will first get the current scope from the current request, thus implementing a Session Per Request pattern. Gets the current stack. The current stack. Validate that the property's value is unique in the database when saved Initializes a new instance of the class. Perform the check that the property value is unqiue in the table true if the field is OK Builds the error message when the property value is not unique Applies the browser validation by setting up one or more input rules on . The config. Type of the input. The generator. The attributes. The target. Gets a value indicating whether this validator supports browser validation. if browser validation is supported; otherwise, . Allow custom executions using the NHibernate's ISession. Base class for all ActiveRecord classes. Implements all the functionality to simplify the code on the subclasses. Base class for ActiveRecord entities that are interested in NHibernate's hooks. Hook to change the object state before saving it. Return true if you have changed the state. false otherwise Hook to transform the read data from the database before populating the object instance id of the obejct list of properties and their values Return true if you have changed the state. false otherwise Hook to perform additional tasks before removing the object instance representation from the database. Called before a flush Called after a flush that actually ends in execution of the SQL statements required to synchronize in-memory state with the database. Called when a transient entity is passed to SaveOrUpdate. The return value determines if the object is saved true - the entity is passed to Save(), resulting in an INSERT false - the entity is passed to Update(), resulting in an UPDATE null - Hibernate uses the unsaved-value mapping to determine if the object is unsaved Called from Flush(). The return value determines whether the entity is updated an array of property indicies - the entity is dirty an empty array - the entity is not dirty null - use Hibernate's default dirty-checking algorithm An array of dirty property indicies or null to choose default behavior Lifecycle method invoked during Save of the entity Lifecycle method invoked during Update of the entity Lifecycle method invoked during Delete of the entity Lifecycle method invoked during Load of the entity The global holder for the session factories. Internally used The type. The model. Internally used The type. An Creates (Saves) a new instance to the database. The ActiveRecord instance to be created on the database Creates (Saves) a new instance to the database and flushes the session. The ActiveRecord instance to be created on the database Creates (Saves) a new instance to the database. The ActiveRecord instance to be created on the database if set to true, the operation will be followed by a session flush. Deletes the instance from the database. The ActiveRecord instance to be deleted Deletes the instance from the database and flushes the session. The ActiveRecord instance to be deleted Deletes the instance from the database. The ActiveRecord instance to be deleted if set to true, the operation will be followed by a session flush. From NHibernate documentation: Persist all reachable transient objects, reusing the current identifier values. Note that this will not trigger the Interceptor of the Session. The instance. The replication mode. Refresh the instance from the database. The ActiveRecord instance to be reloaded Deletes all rows for the specified ActiveRecord type This method is usually useful for test cases. ActiveRecord type on which the rows on the database should be deleted Deletes all rows for the specified ActiveRecord type that matches the supplied HQL condition This method is usually useful for test cases. ActiveRecord type on which the rows on the database should be deleted HQL condition to select the rows to be deleted Deletes all objects, based on the primary keys supplied on . The target ActiveRecord type A list of primary keys The number of objects deleted Persists the modification on the instance state to the database. The ActiveRecord instance to be updated on the database Persists the modification on the instance state to the database and flushes the session. The ActiveRecord instance to be updated on the database Persists the modification on the instance state to the database. The ActiveRecord instance to be updated on the database if set to true, the operation will be followed by a session flush. 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 or instead. The ActiveRecord instance to be saved 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 or instead. The ActiveRecord instance to be saved 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 or instead. The transient instance to be saved The saved ActiveRecord instance 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 or instead. The transient instance to be saved The saved ActiveRecord instance 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 or instead. The ActiveRecord instance to be saved if set to true, the operation will be followed by a session flush. 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 or instead. The transient instance to be saved if set to true, the operation will be followed by a session flush. The saved ActiveRecord instance. Invokes the specified delegate passing a valid NHibernate session. Used for custom NHibernate queries. The target ActiveRecordType The delegate instance The ActiveRecord instance Whatever is returned by the delegate invocation Enumerates the query Note: only use if you expect most of the values to exist on the second level cache. The query. An Executes the query. The query. The query result. Returns the number of records of the specified type in the database [ActiveRecord] public class User : ActiveRecordBase { ... public static int CountAllUsers() { return Count(typeof(User)); } } The target type. The count result Returns the number of records of the specified type in the database [ActiveRecord] public class User : ActiveRecordBase { ... public static int CountAllUsersLocked() { return Count(typeof(User), "IsLocked = ?", true); } } The target type. A sql where string i.e. Person=? and DOB > ? Positional parameters for the filter string The count result Returns the number of records of the specified type in the database The target type. The criteria expression The count result Returns the number of records of the specified type in the database The target type. The criteria expression The count result Check if there is any records in the db for the target type The target type. true if there's at least one row Check if there is any records in the db for the target type The target type. A sql where string i.e. Person=? and DOB > ? Positional parameters for the filter string true if there's at least one row Check if the exists in the database. The target type. The id to check on true if the ID exists; otherwise false. Check if any instance matching the criteria exists in the database. The target type. The criteria expression true if an instance is found; otherwise false. Check if any instance matching the criteria exists in the database. The target type. The criteria expression true if an instance is found; otherwise false. Returns all instances found for the specified type according to the criteria The target type. The criteria. An of objects. The of results. Returns all instances found for the specified type. The target type. The of results Returns all instances found for the specified type using sort orders and criteria. The The target type. An of objects. The criteria expression The of results. Returns all instances found for the specified type using criteria. The target type. The criteria expression The of results. Finds records based on a property value - automatically converts null values to IS NULL style queries. The target type A property name (not a column name) The value to be equals to The of results. Finds records based on a property value - automatically converts null values to IS NULL style queries. The target type The column name to be ordered ASC A property name (not a column name) The value to be equals to The of results. Finds an object instance by an unique ID The AR subclass type ID value The object instance. Finds an object instance by an unique ID The AR subclass type ID value true if you want to catch an exception if the object is not found The object instance. if throwOnNotFound is set to true and the row is not found Searches and returns the first row. The target type. The criteria. The sort order - used to determine which record is the first one. A targetType instance or null. Searches and returns the first row. The target type The sort order - used to determine which record is the first one The criteria expression A targetType instance or null Searches and returns the first row. The target type The criteria expression A targetType instance or null Searches and returns a row. If more than one is found, throws The target type The criteria expression A targetType instance or null Searches and returns a row. If more than one is found, throws The target type The criteria A targetType instance or null Returns a portion of the query results (sliced) The target type. The number of the first row to retrieve. The maximum number of results retrieved. An of objects. The criteria expression The sliced query results. Returns a portion of the query results (sliced) The target type. The number of the first row to retrieve. The maximum number of results retrieved. An of objects. The criteria expression The sliced query results. Returns a portion of the query results (sliced) The target type. The number of the first row to retrieve. The maximum number of results retrieved. The criteria expression The sliced query results. Returns a portion of the query results (sliced) The target type. The number of the first row to retrieve. The maximum number of results retrieved. The criteria expression The sliced query results. Invokes the specified delegate passing a valid NHibernate session. Used for custom NHibernate queries. The delegate instance Whatever is returned by the delegate invocation Saves the instance information to the database. May Create or Update the instance depending on whether it has a valid ID. If within a the operation is going to be on hold until NHibernate (or you) decides to flush the session. Saves the instance information to the database. May Create or Update the instance depending on whether it has a valid ID. Even within a the operation is going to be flushed immediately. This might have side effects such as flushing (persisting) others operations that were on hold. Saves a copy of the instance information to the database. May Create or Update the instance depending on whether it has a valid ID. An saved ActiveRecord instance If within a the operation is going to be on hold until NHibernate (or you) decides to flush the session. Saves a copy of the instance information to the database. May Create or Update the instance depending on whether it has a valid ID. A saved ActiveRecord instance Even within a the operation is going to be flushed immediately. This might have side effects such as flushing (persisting) others operations that were on hold. Creates (Saves) a new instance to the database. If within a the operation is going to be on hold until NHibernate (or you) decides to flush the session. Creates (Saves) a new instance to the database. Even within a the operation is going to be flushed immediately. This might have side effects such as flushing (persisting) others operations that were on hold. Persists the modification on the instance state to the database. If within a the operation is going to be on hold until NHibernate (or you) decides to flush the session. Persists the modification on the instance state to the database. Even within a the operation is going to be flushed immediately. This might have side effects such as flushing (persisting) others operations that were on hold. Deletes the instance from the database. If within a the operation is going to be on hold until NHibernate (or you) decides to flush the session. Deletes the instance from the database. Even within a the operation is going to be flushed immediately. This might have side effects such as flushing (persisting) others operations that were on hold. Refresh the instance from the database. Return the type of the object with its PK value. Useful for logging/debugging A string representation of this object. Ascending Order Returns an array of Ascending instances specifing which properties to use to order a result. List of property names to order by ascending Array of objects suitable for passing to FindAll and variants Descending Order Returns an array of Descending instances specifing which properties to use to order a result. List of property names to order by descending Array of objects suitable for passing to FindAll and variants Base class for all ActiveRecord Generic classes. Implements all the functionality to simplify the code on the subclasses. Creates (Saves) a new instance to the database. The ActiveRecord instance to be created on the database Deletes the instance from the database. The ActiveRecord instance to be deleted Deletes all rows for the specified ActiveRecord type This method is usually useful for test cases. Deletes all rows for the specified ActiveRecord type that matches the supplied HQL condition This method is usually useful for test cases. HQL condition to select the rows to be deleted Deletes all objects, based on the primary keys supplied on . The number of objects deleted Refresh the instance from the database. The ActiveRecord instance to be reloaded Persists the modification on the instance state to the database. The ActiveRecord instance to be updated on the database 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 or instead. The ActiveRecord instance to be saved 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 or instead. The transient instance to be saved The saved ActiveRecord instance. Invokes the specified delegate passing a valid NHibernate session. Used for custom NHibernate queries. The delegate instance The ActiveRecord instance Whatever is returned by the delegate invocation Executes the query and return a strongly typed result The query. The query result. Returns the number of records of in the database [ActiveRecord] public class User : ActiveRecordBase<User> { ... public static int CountAllUsers() { return Count(); // Equivalent to: Count(typeof(User)); } } The count query result Returns the number of records of in the database [ActiveRecord] public class User : ActiveRecordBase<User> { ... public static int CountAllUsersLocked() { return Count("IsLocked = ?", true); // Equivalent to: Count(typeof(User), "IsLocked = ?", true); } } A sql where string i.e. Person=? and DOB > ? Positional parameters for the filter string The count result Check if any instance matching the criteria exists in the database. The criteria expression The count result Returns the number of records of the specified type in the database The criteria expression The count result Check if there is any records in the db for true if there's at least one row Check if there is any records in the db for A sql where string i.e. Person=? and DOB > ? Positional parameters for the filter string true if there's at least one row Check if the exists in the database. The System.Type of the PrimaryKey The id to check on true if the ID exists; otherwise false. Check if any instance matching the criteria exists in the database. The criteria expression true if an instance is found; otherwise false. Check if any instance matching the criteria exists in the database. The criteria expression true if an instance is found; otherwise false. Returns all the instances that match the detached criteria. Detached criteria Optional ordering All entities that match the criteria Returns all instances found for An of Returns all instances found for the specified type using sort orders and criteria. An object. The criteria expression The of results. Returns all instances found for using sort orders and criteria. An of Returns all instances found for using criteria. An of Finds records based on a property value A property name (not a column name) The value to be equals to An of Finds records based on a property value The column name to be ordered ASC A property name (not a column name) The value to be equals to An of Finds an object instance by an unique ID ID value if the row is not found T Finds an object instance by an unique ID. If the row is not found this method will not throw an exception. ID value A Finds an object instance by an unique ID for ID value A Finds an object instance by a unique ID for ID value true if you want to catch an exception if the object is not found A if throwOnNotFound is set to true and the row is not found Searches and returns the first row for . Detached criteria. The sort order - used to determine which record is the first one. A targetType instance or null. Searches and returns the first row for The sort order - used to determine which record is the first one The criteria expression A targetType instance or null Searches and returns the first row for The sort order - used to determine which record is the first one The criteria expression A targetType instance or null Searches and returns the first row for The criteria expression A targetType instance or null Searches and returns a row. If more than one is found, throws The criteria expression A targetType instance or null Searches and returns a row. If more than one is found, throws The criteria A targetType instance or null Returns a portion of the query results (sliced) The number of the first row to retrieve. The maximum number of results retrieved. An of objects. The criteria expression The sliced query results. Returns a portion of the query results (sliced) The number of the first row to retrieve. The maximum number of results retrieved. The criteria expression The sliced query results. Returns a portion of the query results (sliced) The number of the first row to retrieve. The maximum number of results retrieved. An of objects. The criteria expression The sliced query results. This exception is raised when Active Record encounters a problem Initializes a new instance of the class. The message. Initializes a new instance of the class. The message. The inner exception. Initializes a new instance of the class. The that holds the serialized object data about the exception being thrown. The that contains contextual information about the source or destination. The class name is null or is zero (0). The info parameter is null. Exception thrown when an error is detected on the ActiveRecord initialization phase. Initializes a new instance of the class. The message. Initializes a new instance of the class. The message. The inner exception. Initializes a new instance of the class. The that holds the serialized object data about the exception being thrown. The that contains contextual information about the source or destination. The class name is null or is zero (0). The info parameter is null. Allow programmers to use the ActiveRecord functionality without direct reference to Invokes the specified delegate passing a valid NHibernate session. Used for custom NHibernate queries. The target ActiveRecordType The delegate instance The ActiveRecord instance Whatever is returned by the delegate invocation Finds an object instance by its primary key. The AR subclass type ID value true if you want an exception to be thrown if the object is not found if throwOnNotFound is set to true and the row is not found Finds an object instance by its primary key. The AR subclass type ID value Searches and returns the first row. The target type The sort order - used to determine which record is the first one The criteria expression A targetType instance or null Searches and returns the first row. The target type The criteria expression A targetType instance or null Searches and returns the first row. The target type. The criteria. The sort order - used to determine which record is the first one. A targetType instance or null. Searches and returns the first row. The target type The criteria expression A targetType instance or null Searches and returns the a row. If more than one is found, throws The target type The criteria expression A targetType instance or null Searches and returns a row. If more than one is found, throws The target type The criteria A targetType instance or null Returns a portion of the query results (sliced) Returns a portion of the query results (sliced) Returns a portion of the query results (sliced) Returns a portion of the query results (sliced) Returns all instances found for the specified type. Returns all instances found for the specified type using sort orders and criterias. Returns all instances found for the specified type using criterias. Returns all instances found for the specified type according to the criteria Finds records based on a property value - automatically converts null values to IS NULL style queries. The target type A property name (not a column name) The value to be equals to Finds records based on a property value - automatically converts null values to IS NULL style queries. The target type The column name to be ordered ASC A property name (not a column name) The value to be equals to Deletes all entities of the specified type (and their inheritors) The type. Deletes all entities of specified type that match the HQL where clause The type. The where. Deletes all objects, based on the primary keys supplied on . The target ActiveRecord type A list of primary keys The number of objects deleted Enumerates the query. Note: Only use if you expect most of the values to be on the second level cache The query Executes the query The query Returns the number of records of the specified type in the database [ActiveRecord] public class User : ActiveRecordBase { ... public static int CountUsers() { return Count(typeof(User)); } } Type of the target. The count result Returns the number of records of the specified type in the database [ActiveRecord] public class User : ActiveRecordBase { ... public static int CountUsersLocked() { return Count(typeof(User), "IsLocked = ?", true); } } Type of the target. A sql where string i.e. Person=? and DOB > ? Positional parameters for the filter string The count result Returns the number of records of the specified type in the database The target type. The criteria expression The count result Returns the number of records of the specified type in the database The target type. The criteria expression The count result Check if there is any records in the db for the target type Type of the target. true if there's at least one row Check if there is any records in the db for the target type Type of the target. A sql where string i.e. Person=? and DOB > ? Positional parameters for the filter string true if there's at least one row Check if the exists in the database. Type of the target. The id to check on true if the ID exists; otherwise false. Check if any instance matches the criteria. true if an instance is found; otherwise false. Check if any instance matching the criteria exists in the database. The target type. The criteria expression true if an instance is found; otherwise false. Saves the instance to the database The ActiveRecord instance to be deleted 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 or instead. The ActiveRecord instance to be saved Saves a copy of instance to the database The transient instance to be copied The saved ActiveRecord instance 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 or instead. The transient instance to be copied The saved ActiveRecord instance Creates (Saves) a new instance to the database. The ActiveRecord instance to be deleted Creates (Saves) a new instance to the database and flushes the session. The ActiveRecord instance to be created on the database Persists the modification on the instance state to the database. The ActiveRecord instance to be deleted Persists the modification on the instance state to the database and flushes the session. The ActiveRecord instance to be updated on the database Deletes the instance from the database. The ActiveRecord instance to be deleted Deletes the instance from the database and flushes the session. The ActiveRecord instance to be deleted Refresh the instance from the database. The ActiveRecord instance to be reloaded Testing hock only. From NHibernate documentation: Persist all reachable transient objects, reusing the current identifier values. Note that this will not trigger the Interceptor of the Session. The instance. The replication mode. Evicts the specified instance from the first level cache (session level). The instance. Evicts the specified type. The type. Evicts the specified type. The type. The id. Allow programmers to use the ActiveRecord functionality without extending Invokes the specified delegate passing a valid NHibernate session. Used for custom NHibernate queries. The delegate instance The ActiveRecord instance Whatever is returned by the delegate invocation Finds an object instance by its primary key. ID value true if you want an exception to be thrown if the object is not found if throwOnNotFound is set to true and the row is not found Finds an object instance by its primary key. ID value Searches and returns the first row. The sort order - used to determine which record is the first one The criteria expression A targetType instance or null Searches and returns the first row. The criteria expression A targetType instance or null Searches and returns the first row. The criteria. The sort order - used to determine which record is the first one. A targetType instance or null. Searches and returns the first row. The criteria expression A targetType instance or null Searches and returns the first row. The criterias. A instance the targetType or null Searches and returns a row. If more than one is found, throws The criteria A targetType instance or null Finds records based on a property value - automatically converts null values to IS NULL style queries. A property name (not a column name) The value to be equals to Finds records based on a property value - automatically converts null values to IS NULL style queries. The column name to be ordered ASC A property name (not a column name) The value to be equals to Returns all instances found for the specified type. Returns all instances found for the specified type using sort orders and criterias. Returns all instances found for the specified type using criterias. Returns all instances found for the specified type according to the criteria Returns a portion of the query results (sliced) Returns a portion of the query results (sliced) Returns a portion of the query results (sliced) Deletes all entities of . Deletes all entities of that match the HQL where clause. Saves the instance to the database Saves a copy of the instance to the database The saved instance Creates (Saves) a new instance to the database. Persists the modification on the instance state to the database. Deletes the instance from the database. Refresh the instance from the database. The ActiveRecord instance to be reloaded Executes the query and return a strongly typed result The query. Check if the exists in the database. The System.Type of the PrimaryKey The id to check on true if the ID exists; otherwise false. Returns the number of records of the specified type in the database The count result Returns the number of records of the specified type in the database that match the given critera The criteria expression The count result Returns the number of records of the specified type in the database A sql where string i.e. Person=? and DOB > ? Positional parameters for the filter string The count result Returns the number of records of the specified type in the database The criteria expression The count result Check if there is any records in the db for the target type true if there's at least one row Check if there is any records in the db for the target type A sql where string i.e. Person=? and DOB > ? Positional parameters for the filter string true if there's at least one row Check if the exists in the database. The id to check on true if the ID exists; otherwise false. Check if any instance matches the criteria. true if an instance is found; otherwise false. Check if any instance matching the criteria exists in the database. The criteria expression true if an instance is found; otherwise false. Delegate for use in and Delegate for use in and Delegate for use in Performs the framework initialization. This class is not thread safe. This is saved so one can invoke RegisterTypes later Initialize the mappings using the configuration and the list of types Initialize the mappings using the configuration and checking all the types on the specified Assembly Initialize the mappings using the configuration and checking all the types on the specified Assemblies Initializes the framework reading the configuration from the AppDomain and checking all the types on the executing Assembly Registers new assemblies in ActiveRecord Usefull for dynamic assembly-adding after initialization Registers new types in ActiveRecord Usefull for dynamic type-adding after initialization Generates and executes the creation scripts for the database. Generates and executes the creation scripts for the database using the specified baseClass to know which database it should create the schema for. Executes the specified script to create/drop/change the database schema Executes the specified script to create/drop/change the database schema against the specified database connection Generates and executes the Drop scripts for the database. Generates and executes the Drop scripts for the database using the specified baseClass to know which database it should create the scripts for. Generates the drop scripts for the database saving them to the supplied file name. If ActiveRecord was configured to access more than one database, a file is going to be generate for each, based on the path and the fileName specified. Generates the drop scripts for the database saving them to the supplied file name. The baseType is used to identify which database should we act upon. Generates the creation scripts for the database If ActiveRecord was configured to access more than one database, a file is going to be generate for each, based on the path and the fileName specified. Generates the creation scripts for the database The baseType is used to identify which database should we act upon. Intended to be used only by test cases Retrieves a copy of the types registered within ActiveRecord Registers a builder extension. The extension. Return true if the type has a [ActiveRecord] attribute Retrieve all classes decorated with ActiveRecordAttribute or that have been configured as a AR base class. Assembly to retrieve types from Array to store retrieved types in IConfigurationSource to inspect AR base declarations from Generate a file name based on the original file name specified, using the count to give it some order. So others frameworks can intercept the creation and act on the holder instance Allows other frameworks to modify the ActiveRecordModel before the generation of the NHibernate XML configuration. As an example, this may be used to rewrite table names to conform to an application-specific standard. Since the configuration source is passed in, it is possible to determine the underlying database type and make changes if necessary. Allows other frameworks to modify the ActiveRecordModel before the generation of the NHibernate XML configuration. As an example, this may be used to rewrite table names to conform to an application-specific standard. Since the configuration source is passed in, it is possible to determine the underlying database type and make changes if necessary. Allows other frameworks to modify the ActiveRecordModel before the generation of the NHibernate XML configuration. Gets a value indicating whether ActiveRecord was initialized properly (see the Initialize method). true if it is initialized; otherwise, false. Extends adding automatic validation support. using Castle.Components.Validator; public class Customer : ActiveRecordBase { ... [Property, ValidateNonEmpty] public int Name { get { return _name; } set { _name = value; } } [Property, ValidateNonEmpty, ValidateEmail] public int Email { get { return _email; } set { _email = value; } } Constructs an ActiveRecordValidationBase Performs the fields validation. Returns true if no validation error was found. Performs the fields validation for the specified action. Use validators appropriate to the action being performed. True if no validation error was found Override the base hook to call validators required for create. The current state of the object Returns true if the state has changed otherwise false Override the base hook to call validators required for update. object id The previous state of the object The current state of the object Property types Returns true if the state has changed otherwise false Throws an exception explaining why the save or update cannot be executed when fields are not ok to pass. You can override this method to declare a better behavior. Returns a list of current validation errors messages. Maps a specific PropertyInfo to a list of error messages. Useful for frameworks. Extends adding automatic validation support. public class Customer : ActiveRecordBase { ... [Property, ValidateNotEmpty] public int Name { get { return _name; } set { _name = value; } } [Property, ValidateNotEmpty, ValidateEmail] public int Email { get { return _email; } set { _email = value; } } Constructs an ActiveRecordValidationBase Performs the fields validation. Returns true if no validation error was found. Performs the fields validation for the specified action. Use validators appropriate to the action being performed. True if no validation error was found Override the base hook to call validators required for create. The current state of the object Returns true if the state has changed otherwise false Override the base hook to call validators required for update. object id The previous state of the object The current state of the object Property types Returns true if the state has changed otherwise false Throws an exception explaining why the save or update cannot be executed when fields are not ok to pass. You can override this method to declare a better behavior. Returns a list of current validation errors messages. Maps a specific PropertyInfo to a list of error messages. Useful for frameworks. Used to execute a script file to create/update/drop a database schema. Inspired on NHibernate SchemaExport class. Initializes a new instance of the class. The config. Executes the specified script file. Name of the script file. Executes the script parts. The connection. The parts. Opens the file and return an array of seperate commands that it contains Name of the script file. Adds a collection of ICriterion to an ICriteria. The ICriteria that will be modified. The collection of Criterion. Adds a collection of Order (sort by) specifiers to an ICriteria. The ICriteria that will be modified. The collection of Order specifiers. Maps keys to position in the values array. Basically key -> index Initializes a new instance of the class. The names. The values. Determines whether the object contains an element with the specified key. The key to locate in the object. true if the contains an element with the key; otherwise, false. key is null. Adds an element with the provided key and value to the object. The to use as the key of the element to add. The to use as the value of the element to add. An element with the same key already exists in the object. key is null. The is read-only.-or- The has a fixed size. Removes all elements from the object. The object is read-only. Returns an object for the object. An object for the object. Removes the element with the specified key from the object. The key of the element to remove. The object is read-only.-or- The has a fixed size. key is null. Copies the elements of the to an , starting at a particular index. The one-dimensional that is the destination of the elements copied from . The must have zero-based indexing. The zero-based index in array at which copying begins. array is null. index is less than zero. array is multidimensional.-or- index is equal to or greater than the length of array.-or- The number of elements in the source is greater than the available space from index to the end of the destination array. The type of the source cannot be cast automatically to the type of the destination array. Returns an enumerator that iterates through a collection. An object that can be used to iterate through the collection. Gets an object containing the keys of the object. An object containing the keys of the object. Gets an object containing the values in the object. An object containing the values in the object. Gets a value indicating whether the object is read-only. true if the object is read-only; otherwise, false. Gets a value indicating whether the object has a fixed size. true if the object has a fixed size; otherwise, false. Gets or sets the with the specified key. Gets the number of elements contained in the . The number of elements contained in the . Gets an object that can be used to synchronize access to the . An object that can be used to synchronize access to the . Gets a value indicating whether access to the is synchronized (thread safe). true if access to the is synchronized (thread safe); otherwise, false. Simple link list entry Initializes a new instance of the class. The key. The index. Finds the specified key. The key. Translates the IInterceptor messages to instance possible hooks Initializes a new instance of the class. Called just before an object is initialized The interceptor may change the state, which will be propagated to the persistent object. Note that when this method is called, entity will be an empty uninitialized instance of the class. true if the user modified the state in any way Called when an object is detected to be dirty, during a flush. The interceptor may modify the detected currentState, which will be propagated to both the database and the persistent object. Note that all flushes end in an actual synchronization with the database, in which as the new currentState will be propagated to the object, but not necessarily (immediately) to the database. It is strongly recommended that the interceptor not modify the previousState. true if the user modified the currentState in any way Called before an object is saved The interceptor may modify the state, which will be used for the SQL INSERT and propagated to the persistent object true if the user modified the state in any way Called before an object is deleted It is not recommended that the interceptor modify the state. Called before a flush The entities Called after a flush that actually ends in execution of the SQL statements required to synchronize in-memory state with the database. The entitites Called from Flush(). The return value determines whether the entity is updated an array of property indicies - the entity is dirty an empty array - the entity is not dirty null - use Hibernate's default dirty-checking algorithm A persistent entity An array of dirty property indicies or null to choose default behavior Instantiate the entity class. Return to indicate that Hibernate should use the default constructor of the class the name of the entity The type of entity instance to be returned. the identifier of the new instance An instance of the class, or to choose default behaviour The identifier property of the returned instance should be initialized with the given identifier. Gets the sole instance. The instance. Create an interceptor for the session. Allow to override the default for creating the intercetor Create the Creates an instance of the interceptor Type of delegate that is called when a root type is registered. Keeps an association of SessionFactories to a object model tree; Associates a Configuration object to a root type Pendent Requests the Configuration associated to the type. Obtains the SessionFactory associated to the type. Creates a session for the associated type Releases the specified session Called if an action on the session fails Gets the type of the root. The type. This method allows direct registration of a session factory to a type, bypassing the normal preperation that AR usually does. The main usage is in testing, so you would be able to switch the session factory for each test. Note that this will override the current session factory for the baseType. Raised when a new root type is registered. A new root type creates a new ISessionFactory Gets or sets the implementation of This exception is thrown when loading an entity by its PK failed because the entity did not exist. Initializes a new instance of the class. The message. Initializes a new instance of the class. The message. The inner exception. Initializes a new instance of the class. The that holds the serialized object data about the exception being thrown. The that contains contextual information about the source or destination. The class name is null or is zero (0). The info parameter is null. Default implementation of This class is thread safe Associates a Configuration object to a root type Requests the Configuration associated to the type. Pendent Optimized with reader/writer lock. This method allows direct registration of a session factory to a type, bypassing the normal preperation that AR usually does. The main usage is in testing, so you would be able to switch the session factory for each test. Note that this will override the current session factory for the baseType. Creates a session for the associated type Gets the type of the root. The type. Releases the specified session Called if an action on the session fails Raised when a root type is registered. Gets or sets the implementation of HttpModule to set up a session for the request lifetime. To install the module, you must: Add the module to the httpModules configuration section within system.web The key used to store the session in the context items Used to check whether the ThreadScopeInfo being used is suitable for a web environment Initialize the module. The app. Disposes of the resources (other than memory) used by the module that implements . Called when request is started, create a session for the request The sender. The instance containing the event data. Called when the request ends, dipose of the scope The sender. The instance containing the event data. Contains utility methods for dealing with ActiveRecord objects and collections. Useful for external frameworks. Obsolete method, use ActiveRecordMediator or ActiveRecordMediator{T} instead Obsolete method, use ActiveRecordMediator or ActiveRecordMediator{T} instead Obsolete method, use ActiveRecordMediator or ActiveRecordMediator{T} instead Create an array from an IList. Type of the item in the array. The list. Converts the results stored in an to an strongly-typed array. The type of the new array The source list If true, only distinct results will be inserted in the array The strongly-typed array Converts the results stored in an to an strongly-typed array. The type of the new array The source list If the HQL clause selects more than one field, or a join is performed without using fetch join, the contents of the result list will be of type object[]. Specify which index in this array should be used to compose the new result array. Use -1 to ignore this parameter. If true, only distinct results will be inserted in the array The strongly-typed array Converts the results stored in an to an strongly-typed array. The class of the object which will be created for each row contained in the supplied . The source list If true, only distinct results will be inserted in the array The strongly-typed array A good alternative is to use the new Converts the results stored in an to an strongly-typed array. The type of the new array The source list If true, only distinct results will be inserted in the array The strongly-typed array Converts the results stored in an to a strongly-typed array. The source list If true, only distinct results will be inserted in the array The strongly-typed array The class of the object which will be created for each row contained in the supplied . A good alternative is to use the new Converts the results stored in an to an strongly-typed array. The type of the new array The source list If the HQL clause selects more than one field, or a join is performed without using fetch join, the contents of the result list will be of type object[]. Specify which index in this array should be used to compose the new result array. Use -1 to ignore this parameter. If true, only distinct results will be inserted in the array The strongly-typed array This exception is thrown by TransactionScope. Initializes a new instance of the class. The message. Initializes a new instance of the class. The message. The inner exception. Initializes a new instance of the class. The that holds the serialized object data about the exception being thrown. The that contains contextual information about the source or destination. The class name is null or is zero (0). The info parameter is null.