|
From: <ric...@us...> - 2009-11-03 16:11:32
|
Revision: 4817
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4817&view=rev
Author: ricbrown
Date: 2009-11-03 16:11:25 +0000 (Tue, 03 Nov 2009)
Log Message:
-----------
Added overloads for IQueryOver.JoinQueryOver and IQueryOver.Join using aliases.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs
trunk/nhibernate/src/NHibernate/Criterion/QueryOverJoinBuilder.cs
trunk/nhibernate/src/NHibernate/IQueryOver.cs
trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-10-31 18:34:16 UTC (rev 4816)
+++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-11-03 16:11:25 UTC (rev 4817)
@@ -161,6 +161,13 @@
ExpressionProcessor.FindMemberExpression(path.Body)));
}
+ public QueryOver<U> JoinQueryOver<U>(Expression<Func<U>> path)
+ {
+ return new QueryOver<U>(_impl,
+ _criteria.CreateCriteria(
+ ExpressionProcessor.FindMemberExpression(path.Body)));
+ }
+
public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path, Expression<Func<U>> alias)
{
return new QueryOver<U>(_impl,
@@ -169,6 +176,14 @@
ExpressionProcessor.FindMemberExpression(alias.Body)));
}
+ public QueryOver<U> JoinQueryOver<U>(Expression<Func<U>> path, Expression<Func<U>> alias)
+ {
+ return new QueryOver<U>(_impl,
+ _criteria.CreateCriteria(
+ ExpressionProcessor.FindMemberExpression(path.Body),
+ ExpressionProcessor.FindMemberExpression(alias.Body)));
+ }
+
public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path, JoinType joinType)
{
return new QueryOver<U>(_impl,
@@ -177,6 +192,14 @@
joinType));
}
+ public QueryOver<U> JoinQueryOver<U>(Expression<Func<U>> path, JoinType joinType)
+ {
+ return new QueryOver<U>(_impl,
+ _criteria.CreateCriteria(
+ ExpressionProcessor.FindMemberExpression(path.Body),
+ joinType));
+ }
+
public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path, Expression<Func<U>> alias, JoinType joinType)
{
return new QueryOver<U>(_impl,
@@ -186,6 +209,15 @@
joinType));
}
+ public QueryOver<U> JoinQueryOver<U>(Expression<Func<U>> path, Expression<Func<U>> alias, JoinType joinType)
+ {
+ return new QueryOver<U>(_impl,
+ _criteria.CreateCriteria(
+ ExpressionProcessor.FindMemberExpression(path.Body),
+ ExpressionProcessor.FindMemberExpression(alias.Body),
+ joinType));
+ }
+
public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path, Expression<Func<U>> alias)
{
return new QueryOver<U>(_impl,
@@ -194,6 +226,14 @@
ExpressionProcessor.FindMemberExpression(alias.Body)));
}
+ public QueryOver<U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path, Expression<Func<U>> alias)
+ {
+ return new QueryOver<U>(_impl,
+ _criteria.CreateCriteria(
+ ExpressionProcessor.FindMemberExpression(path.Body),
+ ExpressionProcessor.FindMemberExpression(alias.Body)));
+ }
+
public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path)
{
return new QueryOver<U>(_impl,
@@ -201,6 +241,13 @@
ExpressionProcessor.FindMemberExpression(path.Body)));
}
+ public QueryOver<U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path)
+ {
+ return new QueryOver<U>(_impl,
+ _criteria.CreateCriteria(
+ ExpressionProcessor.FindMemberExpression(path.Body)));
+ }
+
public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path, Expression<Func<U>> alias, JoinType joinType)
{
return new QueryOver<U>(_impl,
@@ -210,6 +257,15 @@
joinType));
}
+ public QueryOver<U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path, Expression<Func<U>> alias, JoinType joinType)
+ {
+ return new QueryOver<U>(_impl,
+ _criteria.CreateCriteria(
+ ExpressionProcessor.FindMemberExpression(path.Body),
+ ExpressionProcessor.FindMemberExpression(alias.Body),
+ joinType));
+ }
+
public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path, JoinType joinType)
{
return new QueryOver<U>(_impl,
@@ -218,6 +274,14 @@
joinType));
}
+ public QueryOver<U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path, JoinType joinType)
+ {
+ return new QueryOver<U>(_impl,
+ _criteria.CreateCriteria(
+ ExpressionProcessor.FindMemberExpression(path.Body),
+ joinType));
+ }
+
public QueryOver<T> Join(Expression<Func<T, object>> path, Expression<Func<object>> alias)
{
return AddAlias(
@@ -226,6 +290,14 @@
JoinType.InnerJoin);
}
+ public QueryOver<T> Join(Expression<Func<object>> path, Expression<Func<object>> alias)
+ {
+ return AddAlias(
+ ExpressionProcessor.FindMemberExpression(path.Body),
+ ExpressionProcessor.FindMemberExpression(alias.Body),
+ JoinType.InnerJoin);
+ }
+
public QueryOver<T> Join(Expression<Func<T, object>> path, Expression<Func<object>> alias, JoinType joinType)
{
return AddAlias(
@@ -234,6 +306,14 @@
joinType);
}
+ public QueryOver<T> Join(Expression<Func<object>> path, Expression<Func<object>> alias, JoinType joinType)
+ {
+ return AddAlias(
+ ExpressionProcessor.FindMemberExpression(path.Body),
+ ExpressionProcessor.FindMemberExpression(alias.Body),
+ joinType);
+ }
+
public QueryOverJoinBuilder<T> Inner
{
get { return new QueryOverJoinBuilder<T>(this, JoinType.InnerJoin); }
@@ -394,33 +474,63 @@
IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<T, U>> path)
{ return JoinQueryOver(path); }
+ IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<U>> path)
+ { return JoinQueryOver(path); }
+
IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<T, U>> path, Expression<Func<U>> alias)
{ return JoinQueryOver(path, alias); }
+ IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<U>> path, Expression<Func<U>> alias)
+ { return JoinQueryOver(path, alias); }
+
IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<T, U>> path, JoinType joinType)
{ return JoinQueryOver(path, joinType); }
+ IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<U>> path, JoinType joinType)
+ { return JoinQueryOver(path, joinType); }
+
IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<T, U>> path, Expression<Func<U>> alias, JoinType joinType)
{ return JoinQueryOver(path, alias, joinType); }
+ IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<U>> path, Expression<Func<U>> alias, JoinType joinType)
+ { return JoinQueryOver(path, alias, joinType); }
+
IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path)
{ return JoinQueryOver(path); }
+ IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path)
+ { return JoinQueryOver(path); }
+
IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path, Expression<Func<U>> alias)
{ return JoinQueryOver(path, alias); }
+ IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path, Expression<Func<U>> alias)
+ { return JoinQueryOver(path, alias); }
+
IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path, JoinType joinType)
{ return JoinQueryOver(path, joinType); }
+ IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path, JoinType joinType)
+ { return JoinQueryOver(path, joinType); }
+
IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path, Expression<Func<U>> alias, JoinType joinType)
{ return JoinQueryOver(path, alias, joinType); }
+ IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path, Expression<Func<U>> alias, JoinType joinType)
+ { return JoinQueryOver(path, alias, joinType); }
+
IQueryOver<T> IQueryOver<T>.Join(Expression<Func<T, object>> path, Expression<Func<object>> alias)
{ return Join(path, alias); }
+ IQueryOver<T> IQueryOver<T>.Join(Expression<Func<object>> path, Expression<Func<object>> alias)
+ { return Join(path, alias); }
+
IQueryOver<T> IQueryOver<T>.Join(Expression<Func<T, object>> path, Expression<Func<object>> alias, JoinType joinType)
{ return Join(path, alias, joinType); }
+ IQueryOver<T> IQueryOver<T>.Join(Expression<Func<object>> path, Expression<Func<object>> alias, JoinType joinType)
+ { return Join(path, alias, joinType); }
+
IQueryOverJoinBuilder<T> IQueryOver<T>.Inner
{ get { return new IQueryOverJoinBuilder<T>(this, JoinType.InnerJoin); } }
Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOverJoinBuilder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/QueryOverJoinBuilder.cs 2009-10-31 18:34:16 UTC (rev 4816)
+++ trunk/nhibernate/src/NHibernate/Criterion/QueryOverJoinBuilder.cs 2009-11-03 16:11:25 UTC (rev 4817)
@@ -18,21 +18,41 @@
return root.JoinQueryOver<U>(path, joinType);
}
+ public QueryOver<U> JoinQueryOver<U>(Expression<Func<U>> path)
+ {
+ return root.JoinQueryOver<U>(path, joinType);
+ }
+
public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path, Expression<Func<U>> alias)
{
return root.JoinQueryOver<U>(path, alias, joinType);
}
+ public QueryOver<U> JoinQueryOver<U>(Expression<Func<U>> path, Expression<Func<U>> alias)
+ {
+ return root.JoinQueryOver<U>(path, alias, joinType);
+ }
+
public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path)
{
return root.JoinQueryOver<U>(path, joinType);
}
+ public QueryOver<U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path)
+ {
+ return root.JoinQueryOver<U>(path, joinType);
+ }
+
public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path, Expression<Func<U>> alias)
{
return root.JoinQueryOver<U>(path, alias, joinType);
}
+ public QueryOver<U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path, Expression<Func<U>> alias)
+ {
+ return root.JoinQueryOver<U>(path, alias, joinType);
+ }
+
}
public class IQueryOverJoinBuilder<T> : QueryOverJoinBuilderBase<IQueryOver<T>, T>
@@ -44,21 +64,41 @@
return root.JoinQueryOver<U>(path, joinType);
}
+ public IQueryOver<U> JoinQueryOver<U>(Expression<Func<U>> path)
+ {
+ return root.JoinQueryOver<U>(path, joinType);
+ }
+
public IQueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path, Expression<Func<U>> alias)
{
return root.JoinQueryOver<U>(path, alias, joinType);
}
+ public IQueryOver<U> JoinQueryOver<U>(Expression<Func<U>> path, Expression<Func<U>> alias)
+ {
+ return root.JoinQueryOver<U>(path, alias, joinType);
+ }
+
public IQueryOver<U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path)
{
return root.JoinQueryOver<U>(path, joinType);
}
+ public IQueryOver<U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path)
+ {
+ return root.JoinQueryOver<U>(path, joinType);
+ }
+
public IQueryOver<U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path, Expression<Func<U>> alias)
{
return root.JoinQueryOver<U>(path, alias, joinType);
}
+ public IQueryOver<U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path, Expression<Func<U>> alias)
+ {
+ return root.JoinQueryOver<U>(path, alias, joinType);
+ }
+
}
public class QueryOverJoinBuilderBase<R, T> where R : IQueryOver<T>
@@ -78,6 +118,11 @@
return (R)root.Join(path, alias, joinType);
}
+ public R Join(Expression<Func<object>> path, Expression<Func<object>> alias)
+ {
+ return (R)root.Join(path, alias, joinType);
+ }
+
}
}
Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-10-31 18:34:16 UTC (rev 4816)
+++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-11-03 16:11:25 UTC (rev 4817)
@@ -155,7 +155,7 @@
IQueryOverLockBuilder<T> Lock(Expression<Func<object>> alias);
/// <summary>
- /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity
+ /// Creates a new NHibernate.ICriteria<U>, "rooted" at the associated entity
/// </summary>
/// <typeparam name="U">Type of sub-criteria</typeparam>
/// <param name="path">Lambda expression returning association path</param>
@@ -163,35 +163,71 @@
IQueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path);
/// <summary>
- /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity
+ /// Creates a new NHibernate.ICriteria<U>, "rooted" at the associated entity
/// </summary>
/// <typeparam name="U">Type of sub-criteria</typeparam>
/// <param name="path">Lambda expression returning association path</param>
+ /// <returns>The created "sub criteria"</returns>
+ IQueryOver<U> JoinQueryOver<U>(Expression<Func<U>> path);
+
+ /// <summary>
+ /// Creates a new NHibernate.ICriteria<U>, "rooted" at the associated entity
+ /// </summary>
+ /// <typeparam name="U">Type of sub-criteria</typeparam>
+ /// <param name="path">Lambda expression returning association path</param>
/// <param name="alias">Lambda expression returning alias reference</param>
/// <returns>The created "sub criteria"</returns>
IQueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path, Expression<Func<U>> alias);
/// <summary>
- /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity
+ /// Creates a new NHibernate.ICriteria<U>, "rooted" at the associated entity
/// </summary>
/// <typeparam name="U">Type of sub-criteria</typeparam>
/// <param name="path">Lambda expression returning association path</param>
+ /// <param name="alias">Lambda expression returning alias reference</param>
+ /// <returns>The created "sub criteria"</returns>
+ IQueryOver<U> JoinQueryOver<U>(Expression<Func<U>> path, Expression<Func<U>> alias);
+
+ /// <summary>
+ /// Creates a new NHibernate.ICriteria<U>, "rooted" at the associated entity
+ /// </summary>
+ /// <typeparam name="U">Type of sub-criteria</typeparam>
+ /// <param name="path">Lambda expression returning association path</param>
/// <param name="joinType">Type of join</param>
/// <returns>The created "sub criteria"</returns>
IQueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path, JoinType joinType);
/// <summary>
- /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity
+ /// Creates a new NHibernate.ICriteria<U>, "rooted" at the associated entity
/// </summary>
/// <typeparam name="U">Type of sub-criteria</typeparam>
/// <param name="path">Lambda expression returning association path</param>
+ /// <param name="joinType">Type of join</param>
+ /// <returns>The created "sub criteria"</returns>
+ IQueryOver<U> JoinQueryOver<U>(Expression<Func<U>> path, JoinType joinType);
+
+ /// <summary>
+ /// Creates a new NHibernate.ICriteria<U>, "rooted" at the associated entity
+ /// </summary>
+ /// <typeparam name="U">Type of sub-criteria</typeparam>
+ /// <param name="path">Lambda expression returning association path</param>
/// <param name="alias">Lambda expression returning alias reference</param>
/// <param name="joinType">Type of join</param>
/// <returns>The created "sub criteria"</returns>
IQueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path, Expression<Func<U>> alias, JoinType joinType);
/// <summary>
- /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity
+ /// Creates a new NHibernate.ICriteria<U>, "rooted" at the associated entity
+ /// </summary>
+ /// <typeparam name="U">Type of sub-criteria</typeparam>
+ /// <param name="path">Lambda expression returning association path</param>
+ /// <param name="alias">Lambda expression returning alias reference</param>
+ /// <param name="joinType">Type of join</param>
+ /// <returns>The created "sub criteria"</returns>
+ IQueryOver<U> JoinQueryOver<U>(Expression<Func<U>> path, Expression<Func<U>> alias, JoinType joinType);
+
+ /// <summary>
+ /// Creates a new NHibernate.ICriteria<U>, "rooted" at the associated entity
/// specifying a collection for the join.
/// </summary>
/// <typeparam name="U">Type of sub-criteria (type of the collection)</typeparam>
@@ -200,37 +236,77 @@
IQueryOver<U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path);
/// <summary>
- /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity
+ /// Creates a new NHibernate.ICriteria<U>, "rooted" at the associated entity
/// specifying a collection for the join.
/// </summary>
/// <typeparam name="U">Type of sub-criteria (type of the collection)</typeparam>
/// <param name="path">Lambda expression returning association path</param>
+ /// <returns>The created "sub criteria"</returns>
+ IQueryOver<U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path);
+
+ /// <summary>
+ /// Creates a new NHibernate.ICriteria<U>, "rooted" at the associated entity
+ /// specifying a collection for the join.
+ /// </summary>
+ /// <typeparam name="U">Type of sub-criteria (type of the collection)</typeparam>
+ /// <param name="path">Lambda expression returning association path</param>
/// <param name="alias">Lambda expression returning alias reference</param>
/// <returns>The created "sub criteria"</returns>
IQueryOver<U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path, Expression<Func<U>> alias);
/// <summary>
- /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity
+ /// Creates a new NHibernate.ICriteria<U>, "rooted" at the associated entity
/// specifying a collection for the join.
/// </summary>
/// <typeparam name="U">Type of sub-criteria (type of the collection)</typeparam>
/// <param name="path">Lambda expression returning association path</param>
+ /// <param name="alias">Lambda expression returning alias reference</param>
+ /// <returns>The created "sub criteria"</returns>
+ IQueryOver<U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path, Expression<Func<U>> alias);
+
+ /// <summary>
+ /// Creates a new NHibernate.ICriteria<U>, "rooted" at the associated entity
+ /// specifying a collection for the join.
+ /// </summary>
+ /// <typeparam name="U">Type of sub-criteria (type of the collection)</typeparam>
+ /// <param name="path">Lambda expression returning association path</param>
/// <param name="joinType">Type of join</param>
/// <returns>The created "sub criteria"</returns>
IQueryOver<U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path, JoinType joinType);
/// <summary>
- /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity
+ /// Creates a new NHibernate.ICriteria<U>, "rooted" at the associated entity
/// specifying a collection for the join.
/// </summary>
/// <typeparam name="U">Type of sub-criteria (type of the collection)</typeparam>
/// <param name="path">Lambda expression returning association path</param>
+ /// <param name="joinType">Type of join</param>
+ /// <returns>The created "sub criteria"</returns>
+ IQueryOver<U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path, JoinType joinType);
+
+ /// <summary>
+ /// Creates a new NHibernate.ICriteria<U>, "rooted" at the associated entity
+ /// specifying a collection for the join.
+ /// </summary>
+ /// <typeparam name="U">Type of sub-criteria (type of the collection)</typeparam>
+ /// <param name="path">Lambda expression returning association path</param>
/// <param name="alias">Lambda expression returning alias reference</param>
/// <param name="joinType">Type of join</param>
/// <returns>The created "sub criteria"</returns>
IQueryOver<U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path, Expression<Func<U>> alias, JoinType joinType);
/// <summary>
+ /// Creates a new NHibernate.ICriteria<U>, "rooted" at the associated entity
+ /// specifying a collection for the join.
+ /// </summary>
+ /// <typeparam name="U">Type of sub-criteria (type of the collection)</typeparam>
+ /// <param name="path">Lambda expression returning association path</param>
+ /// <param name="alias">Lambda expression returning alias reference</param>
+ /// <param name="joinType">Type of join</param>
+ /// <returns>The created "sub criteria"</returns>
+ IQueryOver<U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path, Expression<Func<U>> alias, JoinType joinType);
+
+ /// <summary>
/// Join an association, assigning an alias to the joined entity
/// </summary>
/// <param name="path">Lambda expression returning association path</param>
@@ -243,11 +319,28 @@
/// </summary>
/// <param name="path">Lambda expression returning association path</param>
/// <param name="alias">Lambda expression returning alias reference</param>
+ /// <returns>criteria instance</returns>
+ IQueryOver<T> Join(Expression<Func<object>> path, Expression<Func<object>> alias);
+
+ /// <summary>
+ /// Join an association, assigning an alias to the joined entity
+ /// </summary>
+ /// <param name="path">Lambda expression returning association path</param>
+ /// <param name="alias">Lambda expression returning alias reference</param>
/// <param name="joinType">Type of join</param>
/// <returns>criteria instance</returns>
IQueryOver<T> Join(Expression<Func<T, object>> path, Expression<Func<object>> alias, JoinType joinType);
- IQueryOverJoinBuilder<T> Inner { get; }
+ /// <summary>
+ /// Join an association, assigning an alias to the joined entity
+ /// </summary>
+ /// <param name="path">Lambda expression returning association path</param>
+ /// <param name="alias">Lambda expression returning alias reference</param>
+ /// <param name="joinType">Type of join</param>
+ /// <returns>criteria instance</returns>
+ IQueryOver<T> Join(Expression<Func<object>> path, Expression<Func<object>> alias, JoinType joinType);
+
+ IQueryOverJoinBuilder<T> Inner { get; }
IQueryOverJoinBuilder<T> Left { get; }
IQueryOverJoinBuilder<T> Right { get; }
IQueryOverJoinBuilder<T> Full { get; }
Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-10-31 18:34:16 UTC (rev 4816)
+++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-11-03 16:11:25 UTC (rev 4817)
@@ -179,6 +179,23 @@
}
[Test]
+ public void SubCriteria_JoinQueryOver_ToOneAlias()
+ {
+ ICriteria expected =
+ CreateTestCriteria(typeof(Person), "personAlias")
+ .CreateCriteria("personAlias.Father")
+ .Add(Expression.Eq("Name", "test name"));
+
+ Person personAlias = null;
+ IQueryOver<Person> actual =
+ CreateTestQueryOver<Person>(() => personAlias)
+ .JoinQueryOver(() => personAlias.Father) // sub-criteria
+ .Where(f => f.Name == "test name");
+
+ AssertCriteriaAreEqual(expected, actual);
+ }
+
+ [Test]
public void SubCriteria_JoinQueryOver_ToMany()
{
ICriteria expected =
@@ -195,6 +212,23 @@
}
[Test]
+ public void SubCriteria_JoinQueryOver_ToManyAlias()
+ {
+ ICriteria expected =
+ CreateTestCriteria(typeof(Person), "personAlias")
+ .CreateCriteria("personAlias.Children", JoinType.InnerJoin)
+ .Add(Expression.Eq("Nickname", "test name"));
+
+ Person personAlias = null;
+ IQueryOver<Child> actual =
+ CreateTestQueryOver<Person>(() => personAlias)
+ .Inner.JoinQueryOver(() => personAlias.Children) // sub-criteria
+ .Where(c => c.Nickname == "test name");
+
+ AssertCriteriaAreEqual(expected, actual);
+ }
+
+ [Test]
public void SubCriteria_JoinQueryOverCombinations()
{
ICriteria expected =
@@ -243,6 +277,25 @@
}
[Test]
+ public void Alias_JoinAlias()
+ {
+ ICriteria expected =
+ CreateTestCriteria(typeof(Person), "personAlias")
+ .CreateAlias("personAlias.Father", "fatherAlias")
+ .CreateAlias("personAlias.Children", "childAlias", JoinType.InnerJoin);
+
+ Person personAlias = null;
+ Person fatherAlias = null;
+ Child childAlias = null;
+ IQueryOver<Person> actual =
+ CreateTestQueryOver<Person>(() => personAlias)
+ .Join(() => personAlias.Father, () => fatherAlias)
+ .Inner.Join(() => personAlias.Children, () => childAlias);
+
+ AssertCriteriaAreEqual(expected, actual);
+ }
+
+ [Test]
public void Alias_JoinCombinations()
{
ICriteria expected =
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|