Skip to content

Commit 6e42374

Browse files
committed
Revert "Bug-fix on DBNull in ADO adapter"
This should have been in the 0.5 branch. This reverts commit c42acc5.
1 parent c42acc5 commit 6e42374

3 files changed

Lines changed: 5 additions & 17 deletions

File tree

Simple.Data.Ado/DataReaderExtensions.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Linq;
43
using System.Data;
54
using Simple.Data.Extensions;
@@ -45,7 +44,7 @@ private static IEnumerable<IDictionary<string,object>> ToDictionariesImpl(IDataR
4544
while (reader.Read())
4645
{
4746
reader.GetValues(values);
48-
yield return OptimizedDictionary.Create(index, values.Replace(DBNull.Value, null));
47+
yield return OptimizedDictionary.Create(index, values);
4948
}
5049
}
5150

Simple.Data.Ado/DataRecordExtensions.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Linq;
43
using System.Data;
54
using Simple.Data.Extensions;
@@ -30,7 +29,7 @@ public static dynamic ToDynamicRecord(this IDataRecord dataRecord, IDictionary<s
3029

3130
public static Dictionary<string, object> ToDictionary(this IDataRecord dataRecord)
3231
{
33-
return dataRecord.GetFieldNames().ToDictionary(fieldName => fieldName.Homogenize(), fieldName => DBNullToNull(dataRecord[fieldName]));
32+
return dataRecord.GetFieldNames().ToDictionary(fieldName => fieldName.Homogenize(), fieldName => dataRecord[fieldName]);
3433
}
3534

3635
public static IDictionary<string, object> ToDictionary(this IDataRecord dataRecord, IDictionary<string,int> index)
@@ -50,12 +49,7 @@ public static IEnumerable<object> GetValues(this IDataRecord dataRecord)
5049
{
5150
var values = new object[dataRecord.FieldCount];
5251
dataRecord.GetValues(values);
53-
return values.Replace(DBNull.Value, null);
54-
}
55-
56-
private static object DBNullToNull(object source)
57-
{
58-
return source == DBNull.Value ? null : source;
52+
return values;
5953
}
6054
}
6155
}

Simple.Data/Extensions/EnumerableExtensions.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,5 @@ public static IEnumerable<T> ExtendInfinite<T>(this IEnumerable<T> source)
8787
yield return default(T);
8888
}
8989
}
90-
91-
public static IEnumerable<T> Replace<T>(this IEnumerable<T> source, T toReplace, T replaceWith)
92-
{
93-
return source.Select(item => Equals(item, toReplace) ? replaceWith : item);
94-
}
9590
}
9691
}

0 commit comments

Comments
 (0)