Home

Castle Stronghold

HasManyToAnyAttribute API Document

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

Constructors

HasManyToAnyAttribute(Type mapType, String keyColum, String table, Type idType, String typeColumn, String idColumn)

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

ParameterDescription
mapType Type of the map.
keyColum The key colum.
table The table.
idType Type of the id.
typeColumn The type column.
idColumn The id column.

Properties

NameTypeDescription
TypeColumnString Gets or sets the type column.
IdColumnString Gets or sets the id column.
MetaTypeType Gets or sets the type of the meta column
IdTypeType Gets or sets the type of the id column
ColumnKeyString Gets or sets the key column name.
CompositeKeyColumnKeysString[] Gets or sets the names of the column in composite key scenarios.
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