Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Handle DBNull's.

  • Loading branch information...
commit 8dd0c2a7b02100fba96213f2bae5affdb831767f 1 parent 01daae3
@jpobst jpobst authored
Showing with 18 additions and 3 deletions.
  1. +18 −3 mcs/class/WebMatrix.Data/WebMatrix.Data/DynamicRecord.cs
View
21 mcs/class/WebMatrix.Data/WebMatrix.Data/DynamicRecord.cs
@@ -52,13 +52,23 @@ internal DynamicRecord (Dictionary<string, object> fields)
public object this[string name] {
get {
- return fields[name];
+ var retval = fields[name];
+
+ if (retval == DBNull.Value)
+ return null;
+
+ return retval;
}
}
public object this[int index] {
get {
- return fields[Columns[index]];
+ var retval = fields[Columns[index]];
+
+ if (retval == DBNull.Value)
+ return null;
+
+ return retval;
}
}
@@ -69,7 +79,12 @@ public override IEnumerable<string> GetDynamicMemberNames ()
public override bool TryGetMember (GetMemberBinder binder, out object result)
{
- return fields.TryGetValue (binder.Name, out result);
+ bool success = fields.TryGetValue (binder.Name, out result);
+
+ if (result == DBNull.Value)
+ result = null;
+
+ return success;
}
AttributeCollection ICustomTypeDescriptor.GetAttributes ()
Please sign in to comment.
Something went wrong with that request. Please try again.