Skip to content
Browse files

Return default value if it is a value type and null is passed.

  • Loading branch information...
1 parent 2ffb790 commit 9d33fd3be556ff6d1663151c70d0e116617df00a @lanwin lanwin committed Feb 4, 2011
Showing with 3 additions and 3 deletions.
  1. +3 −3 source/MongoDB/Configuration/Mapping/Util/ValueConverter.cs
View
6 source/MongoDB/Configuration/Mapping/Util/ValueConverter.cs
@@ -6,10 +6,10 @@ internal static class ValueConverter
{
public static object Convert(object value, Type type)
{
- var valueType = value != null ? value.GetType() : typeof(object);
+ if(value == null)
+ return type.IsValueType ? Activator.CreateInstance(type) : null;
- if(value==null)
- return null;
+ var valueType = value.GetType();
if(valueType != type)
try

0 comments on commit 9d33fd3

Please sign in to comment.
Something went wrong with that request. Please try again.