Fixing an issue with output parameters that are of type IntPtr
[castle.git] / ActiveRecord / Castle.ActiveRecord / Attributes / HasAndBelongsToManyAttribute.cs
blob5ac8ff54754259e10b5dcd976c721d2720291998
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.ActiveRecord
17 using System;
19 /// <summary>
20 /// Maps a many to many association with an association table.
21 /// </summary>
22 /// <example><code>
23 /// public class Company : ActiveRecordBase
24 /// {
25 /// ...
26 ///
27 /// [HasAndBelongsToMany( typeof(Person), RelationType.Bag, Table="PeopleCompanies", Column="person_id", ColumnKey="company_id" )]
28 /// public IList People
29 /// {
30 /// get { return _people; }
31 /// set { _people = value; }
32 /// }
33 /// }
34 /// </code></example>
35 /// <remarks>The <see cref="ColumnKey"/> must specify the key on the
36 /// association table that points to the primary key of this class. In
37 /// the example, 'company_id' points to 'Company'.
38 /// </remarks>
39 [AttributeUsage(AttributeTargets.Property, AllowMultiple=false), Serializable]
40 public class HasAndBelongsToManyAttribute : RelationAttribute
42 private String columnRef;
43 private String[] compositeKeyColumnRefs;
44 private String columnKey;
45 private String[] compositeKeyColumnKeys;
46 private FetchEnum fetchMethod = FetchEnum.Unspecified;
47 private Type customCollectionType;
49 /// <summary>
50 /// Initializes a new instance of the <see cref="HasAndBelongsToManyAttribute"/> class.
51 /// </summary>
52 /// <param name="mapType">Type of the map.</param>
53 public HasAndBelongsToManyAttribute( Type mapType )
55 this.mapType = mapType;
59 /// <summary>
60 /// Initializes a new instance of the <see cref="HasAndBelongsToManyAttribute"/> class.
61 /// </summary>
62 public HasAndBelongsToManyAttribute()
66 /// <summary>
67 /// Initializes a new instance of the <see cref="HasAndBelongsToManyAttribute"/> class.
68 /// </summary>
69 /// <param name="mapType">Type of the map.</param>
70 /// <param name="type">The type.</param>
71 public HasAndBelongsToManyAttribute( Type mapType, RelationType type ) : this(mapType)
73 base.relType = type;
76 /// <summary>
77 /// Gets or sets the column that represent the other side on the assoication table
78 /// </summary>
79 /// <value>The column ref.</value>
80 public String ColumnRef
82 get { return columnRef; }
83 set { columnRef = value; }
86 /// <summary>
87 /// Gets or sets the composite key columns that represent the other side on the assoication table
88 /// </summary>
89 /// <value>The composite key column refs.</value>
90 public String[] CompositeKeyColumnRefs
92 get { return compositeKeyColumnRefs; }
93 set { compositeKeyColumnRefs = value; }
96 /// <summary>
97 /// Gets or sets the key column name
98 /// </summary>
99 /// <value>The column key.</value>
100 public String ColumnKey
102 get { return columnKey; }
103 set { columnKey = value; }
106 /// <summary>
107 /// Gets or sets the composite key columns names.
108 /// </summary>
109 /// <value>The composite key column keys.</value>
110 public String[] CompositeKeyColumnKeys
112 get { return compositeKeyColumnKeys; }
113 set { compositeKeyColumnKeys = value; }
116 /// <summary>
117 /// Chooses between outer-join fetching
118 /// or sequential select fetching.
119 /// </summary>
120 public FetchEnum Fetch
122 get { return fetchMethod; }
123 set { fetchMethod = value; }
126 /// <summary>
127 /// Provides a custom collection type.
128 /// </summary>
129 public Type CollectionType
131 get { return customCollectionType; }
132 set { customCollectionType = value; }