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
22 /// Represents a SQL query join definition.
23 /// See <see cref="NHibernate.ISession.CreateSQLQuery(string,string[],Type[])"/> for more information.
25 public class SqlQueryJoinDefinition
: IQueryModifier
27 private readonly String associationPath
;
28 private readonly String associationAlias
;
31 /// Initializes a new instance of the <see cref="SqlQueryJoinDefinition"/> class.
33 /// <param name="associationPath">The association path.</param>
34 /// <param name="associationAlias">The association alias.</param>
35 public SqlQueryJoinDefinition(String associationPath
, String associationAlias
)
37 if (associationPath
== null) throw new ArgumentNullException("associationPath");
38 if (associationAlias
== null) throw new ArgumentNullException("associationAlias");
40 this.associationPath
= associationPath
;
41 this.associationAlias
= associationAlias
;
45 /// Gets the path of the assocation
47 public String AssociationPath
49 get { return associationPath; }
53 /// Gets the alias for the association
55 public String AssociationAlias
57 get { return associationAlias; }
60 #region "Apply" method
63 /// Applies this modifier to the query.
65 /// <param name="query">The query</param>
66 void IQueryModifier
.Apply(IQuery query
)
68 ISQLQuery sqlQuery
= query
as ISQLQuery
;
72 sqlQuery
.AddJoin(associationAlias
, associationPath
);