Commit 23e6b64c authored by Marc Gravell's avatar Marc Gravell

Revert "1.50.3-beta1: looks at #637 re `Guid`"

This reverts commit 91725fb3.
parent 4b459895
...@@ -3769,34 +3769,5 @@ class HazGetOnly ...@@ -3769,34 +3769,5 @@ class HazGetOnly
public int Id { get; } public int Id { get; }
public string Name { get; } = "abc"; 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; }
}
} }
} }
...@@ -1762,41 +1762,6 @@ public static char ReadChar(object value) ...@@ -1762,41 +1762,6 @@ public static char ReadChar(object value)
return s[0]; 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> /// <summary>
/// Internal use only /// Internal use only
...@@ -2758,14 +2723,6 @@ private static IDataReader ExecuteReaderImpl(IDbConnection cnn, ref CommandDefin ...@@ -2758,14 +2723,6 @@ private static IDataReader ExecuteReaderImpl(IDbConnection cnn, ref CommandDefin
{ {
return r => ReadNullableChar(r.GetValue(index)); 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) if (type.FullName == LinqBinary)
{ {
return r => Activator.CreateInstance(type, r.GetValue(index)); return r => Activator.CreateInstance(type, r.GetValue(index));
...@@ -3071,11 +3028,6 @@ static LocalBuilder GetTempLocal(ILGenerator il, ref Dictionary<Type, LocalBuild ...@@ -3071,11 +3028,6 @@ static LocalBuilder GetTempLocal(ILGenerator il, ref Dictionary<Type, LocalBuild
il.EmitCall(OpCodes.Call, typeof(SqlMapper).GetMethod( 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] 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 else
{ {
il.Emit(OpCodes.Dup); // stack is now [target][target][value][value] il.Emit(OpCodes.Dup); // stack is now [target][target][value][value]
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"url": "https://github.com/StackExchange/dapper-dot-net" "url": "https://github.com/StackExchange/dapper-dot-net"
} }
}, },
"version": "1.50.3-*", "version": "1.50.2-*",
"authors": [ "Sam Saffron", "Marc Gravell", "Nick Craver" ], "authors": [ "Sam Saffron", "Marc Gravell", "Nick Craver" ],
"description": "A high performance Micro-ORM supporting SQL Server, MySQL, Sqlite, SqlCE, Firebird etc..", "description": "A high performance Micro-ORM supporting SQL Server, MySQL, Sqlite, SqlCE, Firebird etc..",
"title": "Dapper dot net", "title": "Dapper dot net",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment