File tree Expand file tree Collapse file tree 1 file changed +24
-6
lines changed
src/NHibernate/Cfg/XmlHbmBinding Expand file tree Collapse file tree 1 file changed +24
-6
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
1
2
using System . Linq ;
3
+ using NHibernate . Mapping ;
4
+ using NHibernate . Type ;
2
5
3
6
4
7
namespace NHibernate . Cfg . XmlHbmBinding
5
8
{
6
9
public static class MappingLogExtensions
7
10
{
8
- public static void LogMapped ( this Mapping . Property property , IInternalLogger log )
11
+ public static void LogMapped ( this Property property , IInternalLogger log )
9
12
{
10
13
if ( log . IsDebugEnabled )
11
14
{
12
- string msg = "Mapped property: " + property . Name ;
13
- string columns = string . Join ( "," , property . Value . ColumnIterator . Select ( c => c . Text ) . ToArray ( ) ) ;
15
+ var msg = "Mapped property: " + property . Name ;
16
+ var columns = string . Join ( "," , property . Value . ColumnIterator . Select ( c => c . Text ) . ToArray ( ) ) ;
14
17
if ( columns . Length > 0 )
15
18
msg += " -> " + columns ;
16
- if ( property . Type != null )
17
- msg += ", type: " + property . Type . Name ;
19
+ var propertyTypeName = SafeGetPropertyTypeName ( property ) ;
20
+ if ( propertyTypeName != null )
21
+ msg += ", type: " + propertyTypeName ;
18
22
log . Debug ( msg ) ;
19
23
}
20
24
}
25
+
26
+ static string SafeGetPropertyTypeName ( Property property )
27
+ {
28
+ try
29
+ {
30
+ //property.Type property can trigger a type load
31
+ if ( property . Type != null ) return property . Type . Name ;
32
+ }
33
+ catch ( Exception )
34
+ {
35
+ return "<could not load type>" ;
36
+ }
37
+ return null ;
38
+ }
21
39
}
22
- }
40
+ }
You can’t perform that action at this time.
0 commit comments