Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Treat incoming boolean values from MySQL correctly

  • Loading branch information...
commit e31a5f75101a1e23fccb40a2c66ad55d016722c4 1 parent 8a52a09
@TheDistantSea authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 SubSonic.Core/Extensions/Database.cs
View
12 SubSonic.Core/Extensions/Database.cs
@@ -163,8 +163,11 @@ public static void Load<T>(this IDataReader rdr, T item)
{
Type valueType = rdr.GetValue(i).GetType();
if(valueType == typeof(Boolean))
- currentProp.SetValue(item, (rdr.GetValue(i).ToString() == "1"), null);
- else if (currentProp.PropertyType == typeof(Guid))
+ {
+ string value = rdr.GetValue(i).ToString();
+ currentProp.SetValue(item, value == "1" || value == "True", null);
+ }
+ else if(currentProp.PropertyType == typeof(Guid))
currentProp.SetValue(item, rdr.GetGuid(i), null);
else
currentProp.SetValue(item, rdr.GetValue(i).ChangeTypeTo(valueType), null);
@@ -173,7 +176,10 @@ public static void Load<T>(this IDataReader rdr, T item)
{
Type valueType = rdr.GetValue(i).GetType();
if(valueType == typeof(Boolean))
- currentField.SetValue(item, (rdr.GetValue(i).ToString() == "1"));
+ {
+ string value = rdr.GetValue(i).ToString();
+ currentField.SetValue(item, value == "1" || value == "True");
+ }
else if(currentField.FieldType == typeof(Guid))
currentField.SetValue(item, rdr.GetGuid(i));
else

1 comment on commit e31a5f7

@gregkopp

This also works for SQL Server.

Please sign in to comment.
Something went wrong with that request. Please try again.