Skip to content

Commit a77ac1b

Browse files
committed
Fix and use GetIdentifierPropertyType
1 parent 27a2463 commit a77ac1b

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

src/NHibernate/Linq/Visitors/SelectClauseNominator.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ private bool CanBeEvaluatedInHql(MemberExpression memberExpression)
180180
}
181181

182182
var persister = _parameters.SessionFactory.GetEntityPersister(entityName);
183-
var index = persister.EntityMetamodel.GetPropertyIndexOrNull(memberPath);
184-
return index.HasValue || IsIdentifierMember(persister, memberPath);
183+
return persister.EntityMetamodel.GetIdentifierPropertyType(memberPath) != null ||
184+
persister.EntityMetamodel.GetPropertyIndexOrNull(memberPath).HasValue;
185185
}
186186

187187
private bool CanBeEvaluatedInHql(ConditionalExpression conditionalExpression)
@@ -321,17 +321,5 @@ private static bool ContainsAnyOfTypes(IEnumerable<Expression> expressions, para
321321
{
322322
return expressions.Any(o => types.Contains(o.Type));
323323
}
324-
325-
private static bool IsIdentifierMember(IEntityPersister entityPersister, string memberPath)
326-
{
327-
var idName = entityPersister.IdentifierPropertyName;
328-
// Composite key
329-
if (entityPersister.IdentifierType is IAbstractComponentType idComponentType)
330-
{
331-
return idComponentType.PropertyNames.Any(o => (string.IsNullOrEmpty(idName) ? o : $"{idName}.{o}") == memberPath);
332-
}
333-
334-
return idName == memberPath;
335-
}
336324
}
337325
}

0 commit comments

Comments
 (0)