Maps a many to many association with an association table.

Namespace: Castle.ActiveRecord
Assembly:  Castle.ActiveRecord (in Castle.ActiveRecord.dll)
Version: 1.0.3.0

Syntax

C#
[SerializableAttribute]
[AttributeUsageAttribute(AttributeTargets.Property, AllowMultiple = false)]
public class HasAndBelongsToManyAttribute : RelationAttribute

Remarks

The 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'.

Examples

CopyC#
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; }
  }
}

Inheritance Hierarchy

System..::Object
  System..::Attribute
    Castle.ActiveRecord..::WithAccessAttribute
      Castle.ActiveRecord..::BaseAttribute
        Castle.ActiveRecord..::RelationAttribute
          Castle.ActiveRecord..::HasAndBelongsToManyAttribute

See Also