Skip to content

Commit 7fa84e5

Browse files
committed
NH-3670
1 parent 05858b6 commit 7fa84e5

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/NHibernate/Tuple/Component/DynamicMapComponentTuplizer.cs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,28 @@ public override System.Type MappedClass
2727
{
2828
get
2929
{
30-
var ownerFullName = this.component.Owner.MappedClass.FullName;
31-
var roleName = this.component.RoleName;
32-
var spare = roleName.Substring(ownerFullName.Length + 1);
33-
var parts = spare.Split('.');
34-
var prop = null as PropertyInfo;
35-
var owner = this.component.Owner.MappedClass;
36-
37-
for (var i = 0; i < parts.Length; ++i)
30+
if ((this.component != null) && (this.component.Owner.MappedClass != null))
3831
{
39-
prop = owner.GetProperty(parts[i], BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
32+
var ownerFullName = this.component.Owner.MappedClass.FullName;
33+
var roleName = this.component.RoleName;
34+
var spare = roleName.Substring(ownerFullName.Length + 1);
35+
var parts = spare.Split('.');
36+
var prop = null as PropertyInfo;
37+
var owner = this.component.Owner.MappedClass;
4038

41-
owner = prop.PropertyType;
42-
}
39+
for (var i = 0; i < parts.Length; ++i)
40+
{
41+
prop = owner.GetProperty(parts[i], BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
42+
43+
owner = prop.PropertyType;
44+
}
4345

44-
return typeof(IDictionary<string, object>).IsAssignableFrom(prop.PropertyType) ? typeof(IDictionary<string, object>) : typeof(IDictionary);
46+
return typeof(IDictionary<string, object>).IsAssignableFrom(prop.PropertyType) ? typeof(IDictionary<string, object>) : typeof(IDictionary);
47+
}
48+
else
49+
{
50+
return typeof(IDictionary);
51+
}
4552
}
4653
}
4754

0 commit comments

Comments
 (0)