1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
20 using NHibernate
.Type
;
23 /// Represents a SQL query scalar definition.
24 /// See <see cref="NHibernate.ISession.CreateSQLQuery(string,string[],Type[])"/> for more information.
26 public class SqlQueryScalarDefinition
: IQueryModifier
28 private readonly IType scalarType
;
29 private readonly String columnAlias
;
32 /// Initializes a new instance of the <see cref="SqlQueryScalarDefinition"/> class.
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
;
46 /// Gets the scalar type
48 public IType ScalarType
50 get { return scalarType; }
54 /// Gets the column alias for the scalar
56 public String ColumnAlias
58 get { return columnAlias; }
61 #region "Apply" method
64 /// Applies this modifier to the query.
66 /// <param name="query">The query</param>
67 void IQueryModifier
.Apply(IQuery query
)
69 ISQLQuery sqlQuery
= query
as ISQLQuery
;
73 sqlQuery
.AddScalar(columnAlias
, scalarType
);