Permalink
Browse files

Null check in FromDbConverter and ToDbConverter (#431)

  • Loading branch information...
asherber authored and pleb committed Dec 4, 2017
1 parent ce7d730 commit e523b6c8f134e1b706a4e67b44c2ab5137e76e55
Showing with 12 additions and 6 deletions.
  1. +12 −6 PetaPoco/Core/ConventionMapper.cs
@@ -157,16 +157,22 @@ public ConventionMapper()
};
FromDbConverter = (pi, t) =>
{
var valueConverter = pi.GetCustomAttributes(typeof(ValueConverterAttribute), true).FirstOrDefault() as ValueConverterAttribute;
if (valueConverter != null)
return valueConverter.ConvertFromDb;
if (pi != null)
{
var valueConverter = pi.GetCustomAttributes(typeof(ValueConverterAttribute), true).FirstOrDefault() as ValueConverterAttribute;
if (valueConverter != null)
return valueConverter.ConvertFromDb;
}
return null;
};
ToDbConverter = (pi) =>
{
var valueConverter = pi.GetCustomAttributes(typeof(ValueConverterAttribute), true).FirstOrDefault() as ValueConverterAttribute;
if (valueConverter != null)
return valueConverter.ConvertToDb;
if (pi != null)
{
var valueConverter = pi.GetCustomAttributes(typeof(ValueConverterAttribute), true).FirstOrDefault() as ValueConverterAttribute;
if (valueConverter != null)
return valueConverter.ConvertToDb;
}
return null;
};
}

0 comments on commit e523b6c

Please sign in to comment.