Fix for U4-5698 - using method logic from NPoco as it works :)

This commit is contained in:
Jeavon Leopold
2014-10-31 13:29:03 +00:00
parent 3457768646
commit 419531f373

View File

@@ -563,12 +563,13 @@ namespace Umbraco.Core.Persistence
object val = cmd.ExecuteScalarWithRetry();
OnExecutedCommand(cmd);
if (val == null && typeof(T) == typeof(Guid))
{
val = Guid.Empty;
}
if (val == null || val == DBNull.Value)
return default(T);
return (T)Convert.ChangeType(val, typeof(T));
Type t = typeof(T);
Type u = Nullable.GetUnderlyingType(t);
return (T)Convert.ChangeType(val, u ?? t);
}
}
finally