Skip to content

Commit

Permalink
When returning data from a Query, convert DBNull values to null so ca…
Browse files Browse the repository at this point in the history
…n use ?? operator
  • Loading branch information
David Clarke committed Apr 29, 2011
1 parent 976ca19 commit 007d200
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Massive.cs
Expand Up @@ -55,8 +55,8 @@ public static class ObjectExtensions {
public static dynamic RecordToExpando(this IDataReader rdr) { public static dynamic RecordToExpando(this IDataReader rdr) {
dynamic e = new ExpandoObject(); dynamic e = new ExpandoObject();
var d = e as IDictionary<string, object>; var d = e as IDictionary<string, object>;
for (int i = 0; i < rdr.FieldCount; i++) for (int i = 0; i < rdr.FieldCount; i++)
d.Add(rdr.GetName(i), rdr[i]); d.Add(rdr.GetName(i), DBNull.Value.Equals(rdr[i]) ? null : rdr[i]);
return e; return e;
} }
/// <summary> /// <summary>
Expand Down

0 comments on commit 007d200

Please sign in to comment.