Skip to content

Commit

Permalink
Revert "1.50.3-beta1: looks at #637 re Guid"
Browse files Browse the repository at this point in the history
This reverts commit 91725fb.
  • Loading branch information
mgravell committed Jan 6, 2017
1 parent 4b45989 commit 23e6b64
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 78 deletions.
29 changes: 0 additions & 29 deletions Dapper.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3769,34 +3769,5 @@ class HazGetOnly
public int Id { get; }
public string Name { get; } = "abc";
}

[Fact]
public void GuidBytesWork()
{
var guid = Guid.Parse("00112233-4455-6677-8899-aabbccddeeff");
var bytes = BitConverter.ToString(guid.ToByteArray());
try { connection.Execute("drop table GuidBytes"); } catch { }
connection.Execute("create table GuidBytes(a uniqueidentifier not null, b binary(16) not null)");
connection.Execute("insert GuidBytes(a,b) values (@a, @b)", new { a = guid, b = guid });

// via <Guid>
var guid2 = connection.QuerySingle<Guid>("select a from GuidBytes");
guid2.IsEqualTo(guid);

guid2 = connection.QuerySingle<Guid>("select b from GuidBytes");
guid2.IsEqualTo(guid);

// via <HasGuid>
guid2 = connection.QuerySingle<HazGUid>("select a as [Value] from GuidBytes").Value;
guid2.IsEqualTo(guid);

guid2 = connection.QuerySingle<HazGUid>("select b as [Value] from GuidBytes").Value;
guid2.IsEqualTo(guid);
}

public class HazGUid
{
public Guid Value { get; set; }
}
}
}
48 changes: 0 additions & 48 deletions Dapper/SqlMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1762,41 +1762,6 @@ public static char ReadChar(object value)
return s[0];
}

/// <summary>
/// Internal use only
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
#if !COREFX
[Browsable(false)]
#endif
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete(ObsoleteInternalUsageOnly, false)]
public static Guid ReadGuid(object value)
{
if (value == null || value is DBNull) throw new ArgumentNullException(nameof(value));

if (value is byte[]) return new Guid((byte[])value);
if (value is string) return Guid.Parse((string)value);
return (Guid)value;
}

/// <summary>
/// Internal use only
/// </summary>
#if !COREFX
[Browsable(false)]
#endif
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete(ObsoleteInternalUsageOnly, false)]
public static Guid? ReadNullableGuid(object value)
{
if (value == null || value is DBNull) return null;

if (value is byte[]) return new Guid((byte[])value);
if (value is string) return Guid.Parse((string)value);
return (Guid)value;
}

/// <summary>
/// Internal use only
Expand Down Expand Up @@ -2758,14 +2723,6 @@ private static Func<IDataReader, object> GetStructDeserializer(Type type, Type e
{
return r => ReadNullableChar(r.GetValue(index));
}
if (type == typeof(Guid))
{ // this *does* need special handling, though
return r => ReadGuid(r.GetValue(index));
}
if (type == typeof(Guid?))
{
return r => ReadNullableGuid(r.GetValue(index));
}
if (type.FullName == LinqBinary)
{
return r => Activator.CreateInstance(type, r.GetValue(index));
Expand Down Expand Up @@ -3071,11 +3028,6 @@ private static Func<IDataReader, object> GetTypeDeserializerImpl(
il.EmitCall(OpCodes.Call, typeof(SqlMapper).GetMethod(
memberType == typeof(char) ? nameof(SqlMapper.ReadChar) : nameof(SqlMapper.ReadNullableChar), BindingFlags.Static | BindingFlags.Public), null); // stack is now [target][target][typed-value]
}
else if (memberType == typeof(Guid) || memberType == typeof(Guid?))
{
il.EmitCall(OpCodes.Call, typeof(SqlMapper).GetMethod(
memberType == typeof(Guid) ? nameof(SqlMapper.ReadGuid) : nameof(SqlMapper.ReadNullableGuid), BindingFlags.Static | BindingFlags.Public), null); // stack is now [target][target][typed-value]
}
else
{
il.Emit(OpCodes.Dup); // stack is now [target][target][value][value]
Expand Down
2 changes: 1 addition & 1 deletion Dapper/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"url": "https://github.com/StackExchange/dapper-dot-net"
}
},
"version": "1.50.3-*",
"version": "1.50.2-*",
"authors": [ "Sam Saffron", "Marc Gravell", "Nick Craver" ],
"description": "A high performance Micro-ORM supporting SQL Server, MySQL, Sqlite, SqlCE, Firebird etc..",
"title": "Dapper dot net",
Expand Down

0 comments on commit 23e6b64

Please sign in to comment.