Convert DBNull to null #41

Merged
merged 1 commit into from May 9, 2011
Jump to file or symbol
Failed to load files and symbols.
+2 −2
Diff settings

Always

Just for now

View
@@ -55,8 +55,8 @@ public static class ObjectExtensions {
public static dynamic RecordToExpando(this IDataReader rdr) {
dynamic e = new ExpandoObject();
var d = e as IDictionary<string, object>;
- for (int i = 0; i < rdr.FieldCount; i++)
- d.Add(rdr.GetName(i), rdr[i]);
+ for (int i = 0; i < rdr.FieldCount; i++)
+ d.Add(rdr.GetName(i), DBNull.Value.Equals(rdr[i]) ? null : rdr[i]);
return e;
}
/// <summary>