Fixing an issue with output parameters that are of type IntPtr
[castle.git] / ActiveRecord / Castle.ActiveRecord / Attributes / CollectionIDAttribute.cs
blobf00f59018f8e2c078ed328ab6a750ea46495e089
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 /// Defines the values for the generator for the Collection Id values.w
21 /// </summary>
22 [Serializable]
23 public enum CollectionIDType
25 /// <summary>
26 /// Use Identity column (auto number)
27 /// </summary>
28 Identity,
29 /// <summary>
30 /// Use a sequence
31 /// </summary>
32 Sequence,
33 /// <summary>
34 /// Use the HiLo algorithm to get the next value
35 /// </summary>
36 HiLo,
37 /// <summary>
38 /// Use a sequence and a HiLo algorithm - better performance on Oracle
39 /// </summary>
40 SeqHiLo,
41 /// <summary>
42 /// Use the hex representation of a unique identifier
43 /// </summary>
44 UuidHex,
45 /// <summary>
46 /// Use the string representation of a unique identifier
47 /// </summary>
48 UuidString,
49 /// <summary>
50 /// Generate a Guid for the primary key
51 /// Note: You should prefer using GuidComb over this value.
52 /// </summary>
53 Guid,
54 /// <summary>
55 /// Generate a Guid in sequence, so it will have better insert performance in the DB.
56 /// </summary>
57 GuidComb,
58 /// <summary>
59 /// The key value is always assigned.
60 /// </summary>
61 Assigned,
62 /// <summary>
63 /// This is a foreign key to another table
64 /// </summary>
65 Foreign
68 /// <summary>
69 /// Used for a collection that requires a collection id.
70 /// </summary>
71 /// <example><code>
72 /// public class Blog : ActiveRecordBase
73 /// {
74 /// ...
75 ///
76 /// [HasManyAndBelongs/HasMany]
77 /// [CollectionIDAttribute(CollectionIDAttribute.Native)]
78 /// public int Id
79 /// {
80 /// get { return _id; }
81 /// set { _id = value; }
82 /// }
83 /// </code></example>
84 [AttributeUsage(AttributeTargets.Property, AllowMultiple=false), Serializable]
85 public class CollectionIDAttribute : Attribute
87 private CollectionIDType generator = CollectionIDType.Assigned;
88 private String column;
89 private String type;
91 /// <summary>
92 /// Initializes a new instance of the <see cref="CollectionIDAttribute"/> class.
93 /// </summary>
94 /// <param name="generator">The generator.</param>
95 /// <param name="column">The column.</param>
96 /// <param name="ColumnType">Type of the column.</param>
97 public CollectionIDAttribute(CollectionIDType generator, String column, String ColumnType)
99 this.generator = generator;
100 this.column = column;
101 this.type = ColumnType;
104 /// <summary>
105 /// Gets or sets the generator.
106 /// </summary>
107 /// <value>The generator.</value>
108 public CollectionIDType Generator
110 get { return generator; }
111 set { generator = value; }
114 /// <summary>
115 /// Gets or sets the column name
116 /// </summary>
117 /// <value>The column.</value>
118 public String Column
120 get { return column; }
121 set { column = value; }
124 /// <summary>
125 /// Gets or sets the type of the column.
126 /// </summary>
127 /// <value>The type of the column.</value>
128 public String ColumnType
130 get { return type; }
131 set { type = value; }