Skip to content

Commit a35287b

Browse files
committed
Ignore DBNulls
1 parent d72fb05 commit a35287b

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

DataReaderMapper/DataReaderMapper.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ namespace DataReaderMapper
1313
{
1414

1515
private readonly Dictionary<string, PropertyDetails> propertyCache = new Dictionary<string, PropertyDetails>();
16-
16+
1717
private DataReaderMap()
1818
{
19-
19+
2020
}
2121

2222
public static DataReaderMap<T> CreateMap()
2323
{
2424
var map = new DataReaderMap<T>();
2525

26-
var type = typeof(T);
26+
var type = typeof(T);
2727

2828
foreach (var prop in type.GetProperties())
2929
{
@@ -47,8 +47,8 @@ public static DataReaderMap<T> CreateMap()
4747
details.Converter = converterAttr.FirstOrDefault();
4848
}
4949

50-
51-
map.propertyCache.Add(name, details);
50+
51+
map.propertyCache.Add(name, details);
5252

5353
}
5454

@@ -70,7 +70,7 @@ public IEnumerable<T> ProjectToEnumerable(IDataReader reader)
7070
{
7171
var value = reader[prop.Key];
7272

73-
if (value != null)
73+
if (value != null && value != DBNull.Value)
7474
{
7575
if (prop.Value.Converter != null)
7676
{

DataReaderMapper/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]
35+
[assembly: AssemblyVersion("1.0.0.1")]
36+
[assembly: AssemblyFileVersion("1.0.0.1")]

0 commit comments

Comments
 (0)