Fixing an issue with output parameters that are of type IntPtr
[castle.git] / ActiveRecord / Castle.ActiveRecord / Attributes / HasManyAttribute.cs
blob632f59c65af81ee41d2dbd49c138a0ef0167674e
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 one to many association.
21 /// </summary>
22 /// <example><code>
23 /// public class Blog : ActiveRecordBase
24 /// {
25 /// ...
26 ///
27 /// [HasMany(typeof(Post), RelationType.Bag, ColumnKey="Posts", Table="Posts")]
28 /// public IList Posts
29 /// {
30 /// get { return _posts; }
31 /// set { _posts = value; }
32 /// }
33 /// </code></example>
34 [AttributeUsage(AttributeTargets.Property), Serializable]
35 public class HasManyAttribute : RelationAttribute
37 /// <summary>
38 /// The key column
39 /// Cannot exist if compositeKeyColumns has a value
40 /// </summary>
41 protected String keyColumn;
42 /// <summary>
43 /// The composite columns
44 /// Cannot exist with keyColumn != null
45 /// </summary>
46 protected String[] compositeKeyColumns;
48 /// <summary>
49 /// Whether the target type is for dependent objects or not
50 /// </summary>
51 protected bool hasDependentObjects;
53 /// <summary>
54 /// Whether we do outer join fetching for this collection
55 /// </summary>
56 protected FetchEnum fetchMethod = FetchEnum.Unspecified;
58 /// <summary>
59 /// Provides a custom collection type.
60 /// </summary>
61 protected Type customCollectionType;
63 /// <summary>
64 /// Initializes a new instance of the <see cref="HasManyAttribute"/> class.
65 /// </summary>
66 public HasManyAttribute()
71 /// <summary>
72 /// Initializes a new instance of the <see cref="HasManyAttribute"/> class.
73 /// </summary>
74 /// <param name="mapType">Type of the map.</param>
75 public HasManyAttribute(Type mapType)
77 base.mapType = mapType;
80 /// <summary>
81 /// Initializes a new instance of the <see cref="HasManyAttribute"/> class.
82 /// </summary>
83 /// <param name="mapType">Type of items in this association</param>
84 /// <param name="keyColumn">The key column.</param>
85 /// <param name="table">The table.</param>
86 public HasManyAttribute(Type mapType, String keyColumn, String table)
88 this.keyColumn = keyColumn;
89 base.mapType = mapType;
90 base.table = table;
93 /// <summary>
94 /// Gets or sets the key column name.
95 /// </summary>
96 /// <value>The column key.</value>
97 public String ColumnKey
99 get { return keyColumn; }
100 set { keyColumn = value; }
103 /// <summary>
104 /// Gets or sets the names of the column in composite key scenarios.
105 /// </summary>
106 /// <value>The composite key column keys.</value>
107 public String[] CompositeKeyColumnKeys
109 get { return compositeKeyColumns; }
110 set { compositeKeyColumns = value; }
113 /// <summary>
114 /// Whether or not the target type is a dependent object.
115 /// </summary>
116 /// <value>true = the target type is a dependent object</value>
117 public bool DependentObjects
119 get { return hasDependentObjects; }
120 set { hasDependentObjects = value; }
123 /// <summary>
124 /// Chooses between outer-join fetching
125 /// or sequential select fetching.
126 /// </summary>
127 public FetchEnum Fetch
129 get { return fetchMethod; }
130 set { fetchMethod = value; }
133 /// <summary>
134 /// Provides a custom collection type.
135 /// </summary>
136 public Type CollectionType
138 get { return customCollectionType; }
139 set { customCollectionType = value; }