Skip to content

Commit 8ac4b7b

Browse files
committed
Simplified ISupportEntityJoinQueryOver interface
1 parent 5e089e6 commit 8ac4b7b

File tree

3 files changed

+9
-21
lines changed

3 files changed

+9
-21
lines changed

src/NHibernate/Criterion/ISupportEntityJoinQueryOver.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,8 @@
44

55
namespace NHibernate.Criterion
66
{
7-
// 6.0 TODO: merge into IQueryOver.
8-
public interface ISupportEntityJoinQueryOver
9-
{
10-
void JoinEntityAlias<U>(Expression<Func<U>> alias, ICriterion withClause, JoinType joinType, string entityName);
11-
}
12-
137
// 6.0 TODO: merge into IQueryOver<TRoot,TSubType>.
14-
public interface ISupportEntityJoinQueryOver<TRoot>: ISupportEntityJoinQueryOver
8+
public interface ISupportEntityJoinQueryOver<TRoot>
159
{
1610
IQueryOver<TRoot, U> JoinEntityQueryOver<U>(Expression<Func<U>> alias, ICriterion withClause, JoinType joinType, string entityName);
1711
}

src/NHibernate/Criterion/QueryOver.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ public QueryOver<TRoot, U> JoinEntityQueryOver<U>(Expression<Func<U>> alias, Exp
670670

671671
public QueryOver<TRoot, U> JoinEntityQueryOver<U>(Expression<Func<U>> alias, ICriterion withClause, JoinType joinType = JoinType.InnerJoin, string entityName = null)
672672
{
673-
return Create<U>(CreateEntityCriteria(alias, joinType, withClause, entityName));
673+
return Create<U>(criteria.CreateEntityCriteria(alias, withClause, joinType, entityName));
674674
}
675675

676676
public QueryOver<TRoot,TSubType> JoinAlias(Expression<Func<TSubType, object>> path, Expression<Func<object>> alias)
@@ -773,11 +773,6 @@ private QueryOver<TRoot,TSubType> AddAlias(string path, string alias, JoinType j
773773
return this;
774774
}
775775

776-
private ICriteria CreateEntityCriteria<U>(Expression<Func<U>> alias, JoinType joinType, ICriterion withClause, string entityName)
777-
{
778-
return criteria.CreateEntityCriteria(ExpressionProcessor.FindMemberExpression(alias.Body), withClause, joinType, entityName ?? typeof(U).FullName);
779-
}
780-
781776
private QueryOver<TRoot,TSubType> Add(Expression<Func<TSubType, bool>> expression)
782777
{
783778
criteria.Add(ExpressionProcessor.ProcessExpression<TSubType>(expression));
@@ -999,11 +994,6 @@ IQueryOver<TRoot, U> ISupportEntityJoinQueryOver<TRoot>.JoinEntityQueryOver<U>(E
999994
return JoinEntityQueryOver(alias, withClause, joinType, entityName);
1000995
}
1001996

1002-
void ISupportEntityJoinQueryOver.JoinEntityAlias<U>(Expression<Func<U>> alias, ICriterion withClause, JoinType joinType, string entityName)
1003-
{
1004-
CreateEntityCriteria(alias, joinType, withClause, entityName);
1005-
}
1006-
1007997
IQueryOverJoinBuilder<TRoot,TSubType> IQueryOver<TRoot,TSubType>.Inner
1008998
{ get { return new IQueryOverJoinBuilder<TRoot,TSubType>(this, JoinType.InnerJoin); } }
1009999

src/NHibernate/EntityJoinExtensions.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ public static class EntityJoinExtensions
1010
{
1111
public static TThis JoinEntityAlias<TThis, TEntity>(this TThis queryOver, Expression<Func<TEntity>> alias, ICriterion withClause, JoinType joinType = JoinType.InnerJoin, string entityName = null) where TThis : IQueryOver
1212
{
13-
var q = CastOrThrow<ISupportEntityJoinQueryOver>(queryOver);
14-
q.JoinEntityAlias(alias, withClause, joinType, entityName);
13+
CreateEntityCriteria(queryOver.UnderlyingCriteria, alias, withClause, joinType, entityName);
1514
return queryOver;
1615
}
1716

@@ -37,12 +36,17 @@ public static ICriteria CreateEntityAlias(this ICriteria criteria, string alias,
3736
return criteria;
3837
}
3938

40-
public static ICriteria CreateEntityCriteria(this ICriteria criteria, string alias, ICriterion withClause, JoinType joinType, string entityName)
39+
public static ICriteria CreateEntityCriteria(this ICriteria criteria, string alias, ICriterion withClause, JoinType joinType = JoinType.InnerJoin, string entityName = null)
4140
{
4241
var c = CastOrThrow<ISupportEntityJoinCriteria>(criteria);
4342
return c.CreateEntityCriteria(alias, withClause, joinType, entityName);
4443
}
4544

45+
public static ICriteria CreateEntityCriteria<U>(this ICriteria criteria, Expression<Func<U>> alias, ICriterion withClause, JoinType joinType = JoinType.InnerJoin, string entityName = null)
46+
{
47+
return CreateEntityCriteria(criteria, ExpressionProcessor.FindMemberExpression(alias.Body), withClause, joinType, entityName ?? typeof(U).FullName);
48+
}
49+
4650
private static T CastOrThrow<T>(object obj) where T : class
4751
{
4852
return obj as T

0 commit comments

Comments
 (0)