Home

Castle Stronghold

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.

ParameterDescription
mapType Type of the map.

HasAndBelongsToManyAttribute(Type mapType, RelationType type)

Initializes a new instance of the Castle.ActiveRecord.HasAndBelongsToManyAttribute class.

ParameterDescription
mapType Type of the map.
type The type.

Properties

NameTypeDescription
ColumnRefString Gets or sets the column that represent the other side on the assoication table
CompositeKeyColumnRefsString[] Gets or sets the composite key columns that represent the other side on the assoication table
ColumnKeyString Gets or sets the key column name
CompositeKeyColumnKeysString[] Gets or sets the composite key columns names.
RelationTypeRelationType Gets or sets the type of the relation.
MapTypeType Gets or sets the type of the map.
TableString Gets or sets the table for this relation
SchemaString Gets or sets the schema for this relation (dbo., etc)
LazyBoolean Gets or sets a value indicating whether this Castle.ActiveRecord.RelationAttribute is lazy.
InverseBoolean Gets or sets a value indicating whether this Castle.ActiveRecord.RelationAttribute is inverse.
CascadeManyRelationCascadeEnum Gets or sets the cascade options for this Castle.ActiveRecord.RelationAttribute
OrderByString Gets or sets the order by clause for this relation
WhereString Gets or sets the where clause for this relation
SortString Only used with sets
IndexString Only used with maps or list
IndexTypeString Only used with maps
ElementString Use for simple types.
CacheCacheEnum Gets or sets the cache strategy to use for this property
AccessPropertyAccess Gets or sets the access strategy for this property
CustomAccessString Gets or sets the custom access strategy
AccessStringString Gets the access strategy string for NHibernate's mapping.

Google
Search WWW Search castleproject.org