@@ -65,6 +65,10 @@ internal static Exception GetDirectUsageException()
6565 [ Serializable ]
6666 public abstract partial class QueryOver < TRoot > : QueryOver , IQueryOver < TRoot >
6767 {
68+ protected internal QueryOver < TRoot , U > Create < U > ( ICriteria criteria )
69+ {
70+ return new QueryOver < TRoot , U > ( impl , criteria ) ;
71+ }
6872
6973 private IList < TRoot > List ( )
7074 {
@@ -280,7 +284,8 @@ IQueryOver<TRoot> IQueryOver<TRoot>.ReadOnly()
280284 /// Implementation of the <see cref="IQueryOver<TRoot, TSubType>"/> interface
281285 /// </summary>
282286 [ Serializable ]
283- public class QueryOver < TRoot , TSubType > : QueryOver < TRoot > , IQueryOver < TRoot , TSubType >
287+ public class QueryOver < TRoot , TSubType > : QueryOver < TRoot > , IQueryOver < TRoot , TSubType > ,
288+ ISupportEntityJoinQueryOver < TRoot >
284289 {
285290
286291 protected internal QueryOver ( )
@@ -658,6 +663,11 @@ public QueryOver<TRoot,U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path
658663 joinType ) ) ;
659664 }
660665
666+ public QueryOver < TRoot , U > JoinEntityQueryOver < U > ( Expression < Func < U > > alias , JoinType joinType , ICriterion withClause , string entityName )
667+ {
668+ return Create < U > ( CreateEntityCriteria ( alias , joinType , withClause , entityName ) ) ;
669+ }
670+
661671 public QueryOver < TRoot , TSubType > JoinAlias ( Expression < Func < TSubType , object > > path , Expression < Func < object > > alias )
662672 {
663673 return AddAlias (
@@ -758,6 +768,11 @@ private QueryOver<TRoot,TSubType> AddAlias(string path, string alias, JoinType j
758768 return this ;
759769 }
760770
771+ private ICriteria CreateEntityCriteria < U > ( Expression < Func < U > > alias , JoinType joinType , ICriterion withClause , string entityName )
772+ {
773+ return criteria . CreateEntityCriteria ( ExpressionProcessor . FindMemberExpression ( alias . Body ) , joinType , withClause , entityName ?? typeof ( U ) . FullName ) ;
774+ }
775+
761776 private QueryOver < TRoot , TSubType > Add ( Expression < Func < TSubType , bool > > expression )
762777 {
763778 criteria . Add ( ExpressionProcessor . ProcessExpression < TSubType > ( expression ) ) ;
@@ -974,6 +989,17 @@ IQueryOver<TRoot,TSubType> IQueryOver<TRoot,TSubType>.JoinAlias<U>(Expression<Fu
974989 IQueryOver < TRoot , TSubType > IQueryOver < TRoot , TSubType > . JoinAlias < U > ( Expression < Func < IEnumerable < U > > > path , Expression < Func < U > > alias , JoinType joinType , ICriterion withClause )
975990 { return JoinAlias ( path , alias , joinType , withClause ) ; }
976991
992+ IQueryOver < TRoot , U > ISupportEntityJoinQueryOver < TRoot > . JoinEntityQueryOver < U > ( Expression < Func < U > > alias , JoinType joinType , ICriterion withClause , string entityName )
993+ {
994+ return JoinEntityQueryOver ( alias , joinType , withClause , entityName ) ;
995+ }
996+
997+ //6.0 TODO: to remove and merge with extension EntityJoinExtensions.JoinEntityAlias
998+ void ISupportEntityJoinQueryOver . JoinEntityAlias < U > ( Expression < Func < U > > alias , JoinType joinType , ICriterion withClause , string entityName )
999+ {
1000+ CreateEntityCriteria ( alias , joinType , withClause , entityName ) ;
1001+ }
1002+
9771003 IQueryOverJoinBuilder < TRoot , TSubType > IQueryOver < TRoot , TSubType > . Inner
9781004 { get { return new IQueryOverJoinBuilder < TRoot , TSubType > ( this , JoinType . InnerJoin ) ; } }
9791005
0 commit comments