Skip to content

Commit 6e38a84

Browse files
committed
Fix TryGetMappedNullability for CompositeCustomType
Fixes #2937
1 parent 2452db8 commit 6e38a84

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/NHibernate.Test/Linq/TryGetMappedTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,18 @@ public void NestedComponentPropertyCastTest()
272272
o => o?.Name == "component[OtherProperty1]");
273273
}
274274

275+
[Test]
276+
public void CompositePropertyTest()
277+
{
278+
var query = session.Query<Glarch>().Select(o => o.Multiple.count);
279+
AssertSupported(
280+
query,
281+
typeof(Glarch).FullName,
282+
"Multiple.count",
283+
o => o is Int32Type,
284+
o => o?.Name == typeof(MultiplicityType).FullName);
285+
}
286+
275287
[Test]
276288
public void ManyToOneTest()
277289
{

src/NHibernate/Util/ExpressionsHelper.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ internal static bool TryGetMappedNullability(
158158
}
159159

160160
int index;
161-
if (componentType != null)
161+
if (componentType is CompositeCustomType cct)
162+
{
163+
memberPath = memberPath.Remove(memberPath.LastIndexOf('.'));
164+
}
165+
else if (componentType != null)
162166
{
163167
index = Array.IndexOf(
164168
componentType.PropertyNames,

0 commit comments

Comments
 (0)