HasAndBelongsToManyAttribute API Document
Maps a many to many association with an association table.
Quick Note
The Castle.ActiveRecord.HasAndBelongsToManyAttribute.ColumnKey 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'.
Example
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; } } }
Constructors
HasAndBelongsToManyAttribute(Type mapType)
Initializes a new instance of the Castle.ActiveRecord.HasAndBelongsToManyAttribute class.
| Parameter | Description |
|---|---|
| mapType | Type of the map. |
HasAndBelongsToManyAttribute(Type mapType, RelationType type)
Initializes a new instance of the Castle.ActiveRecord.HasAndBelongsToManyAttribute class.
| Parameter | Description |
|---|---|
| mapType | Type of the map. |
| type | The type. |
Properties
| Name | Type | Description |
|---|---|---|
| ColumnRef | String | Gets or sets the column that represent the other side on the assoication table |
| CompositeKeyColumnRefs | String[] | Gets or sets the composite key columns that represent the other side on the assoication table |
| ColumnKey | String | Gets or sets the key column name |
| CompositeKeyColumnKeys | String[] | Gets or sets the composite key columns names. |
| RelationType | RelationType | Gets or sets the type of the relation. |
| MapType | Type | Gets or sets the type of the map. |
| Table | String | Gets or sets the table for this relation |
| Schema | String | Gets or sets the schema for this relation (dbo., etc) |
| Lazy | Boolean | Gets or sets a value indicating whether this Castle.ActiveRecord.RelationAttribute is lazy. |
| Inverse | Boolean | Gets or sets a value indicating whether this Castle.ActiveRecord.RelationAttribute is inverse. |
| Cascade | ManyRelationCascadeEnum | Gets or sets the cascade options for this Castle.ActiveRecord.RelationAttribute |
| OrderBy | String | Gets or sets the order by clause for this relation |
| Where | String | Gets or sets the where clause for this relation |
| Sort | String | Only used with sets |
| Index | String | Only used with maps or list |
| IndexType | String | Only used with maps |
| Element | String | Use for simple types. |
| Cache | CacheEnum | Gets or sets the cache strategy to use for this property |
| Access | PropertyAccess | Gets or sets the access strategy for this property |
| CustomAccess | String | Gets or sets the custom access strategy |
| AccessString | String | Gets the access strategy string for NHibernate's mapping. |