log db value when mapping fails.

This commit is contained in:
kayone 2013-12-01 16:39:03 -08:00
parent 8fc93c7628
commit 9d29df836d
1 changed files with 4 additions and 3 deletions

View File

@ -45,11 +45,12 @@ namespace Marr.Data.Mapping
// Populate entity fields from data reader // Populate entity fields from data reader
foreach (ColumnMap dataMap in mappings) foreach (ColumnMap dataMap in mappings)
{ {
object dbValue = null;
try try
{ {
string colName = dataMap.ColumnInfo.GetColumName(useAltName); string colName = dataMap.ColumnInfo.GetColumName(useAltName);
int ordinal = reader.GetOrdinal(colName); int ordinal = reader.GetOrdinal(colName);
object dbValue = reader.GetValue(ordinal); dbValue = reader.GetValue(ordinal);
// Handle conversions // Handle conversions
if (dataMap.Converter != null) if (dataMap.Converter != null)
@ -72,8 +73,8 @@ namespace Marr.Data.Mapping
} }
catch (Exception ex) catch (Exception ex)
{ {
string msg = string.Format("The DataMapper was unable to load the following field: '{0}'. {1}", string msg = string.Format("The DataMapper was unable to load the following field: '{0}' value: '{1}'. {2}",
dataMap.ColumnInfo.Name, ex.Message); dataMap.ColumnInfo.Name, dbValue, ex.Message);
throw new DataMappingException(msg, ex); throw new DataMappingException(msg, ex);
} }