1
1
using System ;
2
2
using System . Collections . Specialized ;
3
3
using System . Linq ;
4
+ using System . Linq . Expressions ;
4
5
using NHibernate . Engine ;
5
6
using NHibernate . Linq . Clauses ;
6
7
using NHibernate . Linq . Visitors ;
8
+ using NHibernate . Util ;
7
9
using Remotion . Linq ;
8
10
using Remotion . Linq . Clauses ;
9
11
10
12
namespace NHibernate . Linq . ReWriters
11
13
{
12
14
internal interface IIsEntityDecider
13
15
{
14
- bool IsEntity ( System . Type type ) ;
15
- bool IsIdentifier ( System . Type type , string propertyName ) ;
16
+ bool IsEntity ( MemberExpression expression , out bool isIdentifier ) ;
16
17
}
17
18
18
19
public class AddJoinsReWriter : NhQueryModelVisitorBase , IIsEntityDecider
@@ -77,11 +78,15 @@ public override void VisitJoinClause(JoinClause joinClause, QueryModel queryMode
77
78
_currentJoin = null ;
78
79
}
79
80
81
+ // Since v5.3
82
+ [ Obsolete ( "This method has no usages and will be removed in a future version" ) ]
80
83
public bool IsEntity ( System . Type type )
81
84
{
82
85
return _sessionFactory . GetImplementors ( type . FullName ) . Any ( ) ;
83
86
}
84
87
88
+ // Since v5.3
89
+ [ Obsolete ( "This method has no usages and will be removed in a future version" ) ]
85
90
public bool IsIdentifier ( System . Type type , string propertyName )
86
91
{
87
92
var metadata = _sessionFactory . GetClassMetadata ( type ) ;
@@ -99,5 +104,14 @@ private void AddJoin(QueryModel queryModel, NhJoinClause joinClause)
99
104
100
105
queryModel . BodyClauses . Add ( joinClause ) ;
101
106
}
107
+
108
+ bool IIsEntityDecider . IsEntity ( MemberExpression expression , out bool isIdentifier )
109
+ {
110
+ isIdentifier =
111
+ ExpressionsHelper . TryGetMappedType ( _sessionFactory , expression , out var mappedType , out var entityPersister , out _ , out var memberPath )
112
+ && entityPersister ? . IdentifierPropertyName == memberPath ;
113
+
114
+ return mappedType ? . IsEntityType == true ;
115
+ }
102
116
}
103
117
}
0 commit comments