Skip to content

Commit

Permalink
NH-2779 - Fix possible InvalidCastException for un-fetched properties…
Browse files Browse the repository at this point in the history
… and unknown back-refs.
  • Loading branch information
hazzik committed Oct 16, 2014
1 parent c09b595 commit ae3f056
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/NHibernate/Impl/Printer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using System.Collections.Generic;

using NHibernate.Engine;
using NHibernate.Intercept;
using NHibernate.Metadata;
using NHibernate.Properties;
using NHibernate.Type;
using NHibernate.Util;

Expand Down Expand Up @@ -41,7 +43,15 @@ public string ToString(object entity, EntityMode entityMode)

for (int i = 0; i < types.Length; i++)
{
result[names[i]] = types[i].ToLoggableString(values[i], _factory);
var value = values[i];
if (Equals(LazyPropertyInitializer.UnfetchedProperty, value) || Equals(BackrefPropertyAccessor.Unknown, value))
{
result[names[i]] = value.ToString();
}
else
{
result[names[i]] = types[i].ToLoggableString(value, _factory);
}
}

return cm.EntityName + CollectionPrinter.ToString(result);
Expand Down

0 comments on commit ae3f056

Please sign in to comment.