Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / ActiveRecord / Castle.ActiveRecord / Framework / Queries / Modifiers / SqlQueryScalarDefinition.cs
blobb56cb6256a97a3d7fd8dcace42903908338858ec
1 // Copyright 2004-2007 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.Queries.Modifiers
17 using System;
19 using NHibernate;
20 using NHibernate.Type;
22 /// <summary>
23 /// Represents a SQL query scalar definition.
24 /// See <see cref="NHibernate.ISession.CreateSQLQuery(string,string[],Type[])"/> for more information.
25 /// </summary>
26 public class SqlQueryScalarDefinition : IQueryModifier
28 private readonly IType scalarType;
29 private readonly String columnAlias;
31 /// <summary>
32 /// Initializes a new instance of the <see cref="SqlQueryScalarDefinition"/> class.
33 /// </summary>
34 /// <param name="scalarType">The scalar type.</param>
35 /// <param name="columnAlias">The column alias.</param>
36 public SqlQueryScalarDefinition(IType scalarType, String columnAlias)
38 if (scalarType == null) throw new ArgumentNullException("scalarType");
39 if (columnAlias == null) throw new ArgumentNullException("columnAlias");
41 this.scalarType = scalarType;
42 this.columnAlias = columnAlias;
45 /// <summary>
46 /// Gets the scalar type
47 /// </summary>
48 public IType ScalarType
50 get { return scalarType; }
53 /// <summary>
54 /// Gets the column alias for the scalar
55 /// </summary>
56 public String ColumnAlias
58 get { return columnAlias; }
61 #region "Apply" method
63 /// <summary>
64 /// Applies this modifier to the query.
65 /// </summary>s
66 /// <param name="query">The query</param>
67 void IQueryModifier.Apply(IQuery query)
69 ISQLQuery sqlQuery = query as ISQLQuery;
71 if (sqlQuery != null)
73 sqlQuery.AddScalar(columnAlias, scalarType);
77 #endregion