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.

Remarks

This is supplied for advanced sceanrios.

Examples

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:
CopyC#
[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

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

Syntax

C#
[SerializableAttribute]
[AttributeUsageAttribute(AttributeTargets.Property)]
public class HasManyToAnyAttribute : HasManyAttribute

Inheritance Hierarchy

System..::Object
  System..::Attribute
    Castle.ActiveRecord..::WithAccessAttribute
      Castle.ActiveRecord..::BaseAttribute
        Castle.ActiveRecord..::RelationAttribute
          Castle.ActiveRecord..::HasManyAttribute
            Castle.ActiveRecord..::HasManyToAnyAttribute

See Also