@@ -8,6 +8,8 @@ namespace NHibernate
8
8
{
9
9
public static class EntityJoinExtensions
10
10
{
11
+ #region QueryOver extensions
12
+
11
13
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
12
14
{
13
15
CreateEntityCriteria ( queryOver . UnderlyingCriteria , alias , withClause , joinType , entityName ) ;
@@ -30,13 +32,23 @@ public static IQueryOver<TRoot, TEntity> JoinEntityQueryOver<TRoot, TEntity>(thi
30
32
return q . JoinEntityQueryOver ( alias , withClause , joinType , entityName ) ;
31
33
}
32
34
35
+ #endregion QueryOver extensions
36
+
37
+ #region Criteria extensions
38
+
33
39
public static ICriteria CreateEntityAlias ( this ICriteria criteria , string alias , ICriterion withClause , JoinType joinType , string entityName )
34
40
{
35
41
CreateEntityCriteria ( criteria , alias , withClause , joinType , entityName ) ;
36
42
return criteria ;
37
43
}
44
+
45
+ public static ICriteria CreateEntityAlias < U > ( this ICriteria criteria , Expression < Func < U > > alias , ICriterion withClause , JoinType joinType = JoinType . InnerJoin , string entityName = null )
46
+ {
47
+ CreateEntityCriteria ( criteria , alias , withClause , joinType , entityName ) ;
48
+ return criteria ;
49
+ }
38
50
39
- public static ICriteria CreateEntityCriteria ( this ICriteria criteria , string alias , ICriterion withClause , JoinType joinType = JoinType . InnerJoin , string entityName = null )
51
+ public static ICriteria CreateEntityCriteria ( this ICriteria criteria , string alias , ICriterion withClause , JoinType joinType , string entityName )
40
52
{
41
53
var c = CastOrThrow < ISupportEntityJoinCriteria > ( criteria ) ;
42
54
return c . CreateEntityCriteria ( alias , withClause , joinType , entityName ) ;
@@ -47,10 +59,12 @@ public static ICriteria CreateEntityCriteria<U>(this ICriteria criteria, Express
47
59
return CreateEntityCriteria ( criteria , ExpressionProcessor . FindMemberExpression ( alias . Body ) , withClause , joinType , entityName ?? typeof ( U ) . FullName ) ;
48
60
}
49
61
62
+ #endregion Criteria extensions
63
+
50
64
private static T CastOrThrow < T > ( object obj ) where T : class
51
65
{
52
66
return obj as T
53
- ?? throw new ArgumentException ( $ "{ obj . GetType ( ) . FullName } requires to implement { nameof ( T ) } interface to support explicit entity joins.") ;
67
+ ?? throw new ArgumentException ( $ "{ obj . GetType ( ) . FullName } requires to implement { typeof ( T ) . FullName } interface to support explicit entity joins.") ;
54
68
}
55
69
}
56
70
}
0 commit comments