Fixing an issue with output parameters that are of type IntPtr
[castle.git] / ActiveRecord / Castle.ActiveRecord / Attributes / ActiveRecordAttribute.cs
blobc41df4bb863cd6ddea53ff7d0c336564ca919004
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;
18 using NHibernate.Persister.Entity;
20 /// <summary>
21 /// Associate meta information related to the
22 /// desired table mapping.
23 /// </summary>
24 /// <example>
25 /// <code>
26 /// [ActiveRecord("tb_Order")]
27 /// public class Order : ActiveRecordBase
28 /// {
29 /// }
30 /// </code>
31 /// </example>
32 /// <remarks>
33 /// If no table is specified, the class name
34 /// is used as table name
35 /// </remarks>
36 [AttributeUsage(AttributeTargets.Class, AllowMultiple=false), Serializable]
37 public class ActiveRecordAttribute : BaseAttribute
39 private String table;
40 private String schema;
41 private String discriminatorType;
42 private String discriminatorValue;
43 private String discriminatorColumn;
44 private String discriminatorLength;
45 private String where;
46 private Type proxy;
47 private Type persister;
48 private bool lazy;
49 private bool dynamicUpdate;
50 private bool dynamicInsert;
51 private bool selectBeforeUpdate;
52 private bool mutable = true;
53 private bool useAutoImport = true;
54 private int batchSize = 1;
55 private Polymorphism polymorphism = Polymorphism.Implicit;
56 private OptimisticLocking locking = OptimisticLocking.Version;
57 private bool lazySpecified;
59 /// <summary>
60 /// Uses the class name as table name
61 /// </summary>
62 public ActiveRecordAttribute() {}
64 /// <summary>
65 /// Associates the specified table with the target type
66 /// </summary>
67 /// <param name="table"></param>
68 public ActiveRecordAttribute(String table)
70 this.table = table;
73 /// <summary>
74 /// Associates the specified table and schema with the target type
75 /// </summary>
76 public ActiveRecordAttribute(String table, String schema)
78 this.table = table;
79 this.schema = schema;
82 /// <summary>
83 /// Gets or sets the table name associated with the type
84 /// </summary>
85 public String Table
87 get { return table; }
88 set { table = value; }
91 /// <summary>
92 /// Gets or sets the schema name associated with the type
93 /// </summary>
94 public String Schema
96 get { return schema; }
97 set { schema = value; }
100 /// <summary>
101 /// Associates a proxy type with the target type
102 /// </summary>
103 public Type Proxy
105 get { return proxy; }
106 set { proxy = value; }
109 /// <summary>
110 /// Gets or sets the Discriminator column for
111 /// a table inheritance modeling
112 /// </summary>
113 public String DiscriminatorColumn
115 get { return discriminatorColumn; }
116 set { discriminatorColumn = value; }
119 /// <summary>
120 /// Gets or sets the column type (like string or integer)
121 /// for the discriminator column
122 /// </summary>
123 public String DiscriminatorType
125 get { return discriminatorType; }
126 set { discriminatorType = value; }
129 /// <summary>
130 /// Gets or sets the value that represents the
131 /// target class on the discriminator column
132 /// </summary>
133 public String DiscriminatorValue
135 get { return discriminatorValue; }
136 set { discriminatorValue = value; }
139 /// <summary>
140 /// Gets or sets the length of the discriminator
141 /// column (valid for string type only)
142 /// </summary>
143 public String DiscriminatorLength
145 get { return discriminatorLength; }
146 set { discriminatorLength = value; }
149 /// <summary>
150 /// SQL condition to retrieve objects
151 /// </summary>
152 public String Where
154 get { return where; }
155 set { where = value; }
158 /// <summary>
159 /// Enable lazy loading for the type
160 /// </summary>
161 public bool Lazy
163 get { return lazy; }
166 lazySpecified = true;
167 lazy = value;
171 /// <summary>
172 /// Gets a value indicating whether explicit lazy behavior was specified.
173 /// If explicit lazy behavior was not specified, it goes to the configuration to decide if the type should
174 /// be lazy or not.
175 /// </summary>
176 public bool LazySpecified
178 get { return this.lazySpecified; }
181 /// <summary>
182 /// From NHibernate documentation:
183 /// Specifies that UPDATE SQL should be
184 /// generated at runtime and contain only
185 /// those columns whose values have changed.
186 /// </summary>
187 public bool DynamicUpdate
189 get { return dynamicUpdate; }
190 set { dynamicUpdate = value; }
193 /// <summary>
194 /// From NHibernate documentation:
195 /// Specifies that INSERT SQL should be
196 /// generated at runtime and contain only
197 /// the columns whose values are not null.
198 /// </summary>
199 public bool DynamicInsert
201 get { return dynamicInsert; }
202 set { dynamicInsert = value; }
205 /// <summary>
206 /// From NHibernate documentation:
207 /// Specifies a custom <see cref="IEntityPersister"/>.
208 /// </summary>
209 public Type Persister
211 get { return persister; }
212 set { persister = value; }
215 /// <summary>
216 /// From NHibernate documentation:
217 /// Specifies that NHibernate should never perform an SQL UPDATE
218 /// unless it is certain that an object is actually modified. In
219 /// certain cases (actually, only when a transient object has
220 /// been associated with a new session using update()), this means
221 /// that NHibernate will perform an extra SQL SELECT to determine
222 /// if an UPDATE is actually required.
223 /// </summary>
224 public bool SelectBeforeUpdate
226 get { return selectBeforeUpdate; }
227 set { selectBeforeUpdate = value; }
230 /// <summary>
231 /// From NHibernate documentation:
232 /// Determines whether implicit or explicit query polymorphism is used.
233 /// </summary>
234 public Polymorphism Polymorphism
236 get { return polymorphism; }
237 set { polymorphism = value; }
240 /// <summary>
241 /// From NHibernate documentation:
242 /// Specifies that instances of the class are (not) mutable.
243 /// </summary>
244 public bool Mutable
246 get { return mutable; }
247 set { mutable = value; }
250 /// <summary>
251 /// From NHibernate documentation:
252 /// Specify a "batch size" for fetching instances of
253 /// this class by identifier.
254 /// </summary>
255 public int BatchSize
257 get { return batchSize; }
258 set { batchSize = value; }
261 /// <summary>
262 /// From NHibernate documentation:
263 /// Determines the optimistic locking strategy.
264 /// </summary>
265 public OptimisticLocking Locking
267 get { return locking; }
268 set { locking = value; }
271 /// <summary>
272 /// From NHibernate documentation:
273 /// The auto-import attribute lets us use
274 /// unqualified class names in the query language,
275 /// by default. The assembly and namespace attributes
276 /// specify the assembly where persistent classes
277 /// are located and the namespace they are declared in.
278 /// </summary>
279 public bool UseAutoImport
281 get { return useAutoImport; }
282 set { useAutoImport = value; }