Skip to content

Commit a38c0ab

Browse files
committed
code review
1 parent c646b2d commit a38c0ab

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/NHibernate/Engine/TableGroupJoinHelper.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ private static bool NeedsTableGroupJoin(IReadOnlyList<IJoin> joins, SqlString[]
6868

6969
foreach (var join in joins)
7070
{
71-
var entityPersister = GetEntityPersister(join.Joinable, out var collection);
71+
var entityPersister = GetEntityPersister(join.Joinable, out var isManyToMany);
7272
if (entityPersister?.HasSubclassJoins(includeSubclasses && isSubclassIncluded(join.Alias)) != true)
7373
continue;
7474

7575
if (hasWithClause)
7676
return true;
7777

78-
if (collection?.IsManyToMany != true // many-to-many keys are stored in separate table
78+
if (!isManyToMany // many-to-many keys are stored in separate table
7979
&& entityPersister.ColumnsDependOnSubclassJoins(join.RHSColumns))
8080
return true;
8181
}
@@ -92,14 +92,14 @@ private static SqlString GetTableGroupJoinWithClause(SqlString[] withClauseFragm
9292
var isAssociationJoin = lhsColumns.Length > 0;
9393
if (isAssociationJoin)
9494
{
95-
var entityPersister = GetEntityPersister(first.Joinable, out var collection);
95+
var entityPersister = GetEntityPersister(first.Joinable, out var isManyToMany);
9696
string rhsAlias = first.Alias;
9797
string[] rhsColumns = first.RHSColumns;
9898
for (int j = 0; j < lhsColumns.Length; j++)
9999
{
100100
fromFragment.Add(lhsColumns[j])
101101
.Add("=")
102-
.Add(entityPersister == null || collection?.IsManyToMany == true // many-to-many keys are stored in separate table
102+
.Add((entityPersister == null || isManyToMany) // many-to-many keys are stored in separate table
103103
? rhsAlias
104104
: entityPersister.GenerateTableAliasForColumn(rhsAlias, rhsColumns[j]))
105105
.Add(".")
@@ -114,13 +114,14 @@ private static SqlString GetTableGroupJoinWithClause(SqlString[] withClauseFragm
114114
return fromFragment.ToSqlString();
115115
}
116116

117-
private static AbstractEntityPersister GetEntityPersister(IJoinable joinable, out IQueryableCollection collection)
117+
private static AbstractEntityPersister GetEntityPersister(IJoinable joinable, out bool isManyToMany)
118118
{
119-
collection = null;
119+
isManyToMany = false;
120120
if (!joinable.IsCollection)
121121
return joinable as AbstractEntityPersister;
122122

123-
collection = (IQueryableCollection) joinable;
123+
var collection = (IQueryableCollection) joinable;
124+
isManyToMany = collection.IsManyToMany;
124125
return collection.ElementType.IsEntityType ? collection.ElementPersister as AbstractEntityPersister : null;
125126
}
126127

0 commit comments

Comments
 (0)