From 9d29df836dc8481bd943b5084b7c97c92cd2cddf Mon Sep 17 00:00:00 2001 From: kayone Date: Sun, 1 Dec 2013 16:39:03 -0800 Subject: [PATCH] log db value when mapping fails. --- src/Marr.Data/Mapping/MappingHelper.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Marr.Data/Mapping/MappingHelper.cs b/src/Marr.Data/Mapping/MappingHelper.cs index 0b4c73681..c1fbd42b4 100644 --- a/src/Marr.Data/Mapping/MappingHelper.cs +++ b/src/Marr.Data/Mapping/MappingHelper.cs @@ -45,11 +45,12 @@ namespace Marr.Data.Mapping // Populate entity fields from data reader foreach (ColumnMap dataMap in mappings) { + object dbValue = null; try { string colName = dataMap.ColumnInfo.GetColumName(useAltName); int ordinal = reader.GetOrdinal(colName); - object dbValue = reader.GetValue(ordinal); + dbValue = reader.GetValue(ordinal); // Handle conversions if (dataMap.Converter != null) @@ -72,8 +73,8 @@ namespace Marr.Data.Mapping } catch (Exception ex) { - string msg = string.Format("The DataMapper was unable to load the following field: '{0}'. {1}", - dataMap.ColumnInfo.Name, ex.Message); + string msg = string.Format("The DataMapper was unable to load the following field: '{0}' value: '{1}'. {2}", + dataMap.ColumnInfo.Name, dbValue, ex.Message); throw new DataMappingException(msg, ex); }