Skip to content

Commit cb53d04

Browse files
committed
Fix exception when mapping nested generic classes
If the generic is declared in the outer class and the inner class is mapped, there is no ` in the name of the inner class.
1 parent 4900f06 commit cb53d04

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/FluentNHibernate/Mapping/ClassMap.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,11 @@ string GetDefaultTableName()
691691
if (EntityType.IsGenericType)
692692
{
693693
// special case for generics: GenericType_GenericParameterType
694-
tableName = EntityType.Name.Substring(0, EntityType.Name.IndexOf('`'));
694+
var genericQuoteIndex = EntityType.Name.IndexOf('`');
695+
if (genericQuoteIndex >= 0)
696+
{
697+
tableName = EntityType.Name.Substring(0, genericQuoteIndex);
698+
} // else generic declaration not directly in this class
695699

696700
foreach (var argument in EntityType.GetGenericArguments())
697701
{

0 commit comments

Comments
 (0)