Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Convert DBNull to null #41

Merged
merged 1 commit into from

2 participants

@daveclarke

When returning data from a Query, convert DBNull values to null so can use ?? operator

@robconery robconery merged commit 8964785 into FransBouma:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 29, 2011
  1. When returning data from a Query, convert DBNull values to null so ca…

    David Clarke authored
    …n use ?? operator
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 Massive.cs
View
4 Massive.cs
@@ -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>
Something went wrong with that request. Please try again.