Skip to content

Commit 2ab1305

Browse files
committed
Fix and use GetIdentifierPropertyType
1 parent 5218dc7 commit 2ab1305

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-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)
@@ -322,17 +322,5 @@ private static bool ContainsAnyOfTypes(IEnumerable<Expression> expressions, para
322322
{
323323
return expressions.Any(o => types.Contains(o.Type));
324324
}
325-
326-
private static bool IsIdentifierMember(IEntityPersister entityPersister, string memberPath)
327-
{
328-
var idName = entityPersister.IdentifierPropertyName;
329-
// Composite key
330-
if (entityPersister.IdentifierType is IAbstractComponentType idComponentType)
331-
{
332-
return idComponentType.PropertyNames.Any(o => (string.IsNullOrEmpty(idName) ? o : $"{idName}.{o}") == memberPath);
333-
}
334-
335-
return idName == memberPath;
336-
}
337325
}
338326
}

src/NHibernate/Tuple/Entity/EntityMetamodel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public EntityMetamodel(PersistentClass persistentClass, ISessionFactoryImplement
9494

9595
identifierProperty = PropertyFactory.BuildIdentifierProperty(persistentClass,
9696
sessionFactory.GetIdentifierGenerator(rootName));
97+
MapIdentifierPropertyTypes(identifierProperty);
9798

9899
versioned = persistentClass.IsVersioned;
99100

0 commit comments

Comments
 (0)