From d9ef0084c38ddf090a62b670ea769b1bc6badcc8 Mon Sep 17 00:00:00 2001 From: mgravell Date: Tue, 7 Jun 2011 21:39:03 +0100 Subject: [PATCH] binary as a naked type --- Dapper/SqlMapper.cs | 8 +++++--- Tests/Tests.cs | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Dapper/SqlMapper.cs b/Dapper/SqlMapper.cs index 17680cd..277a82e 100644 --- a/Dapper/SqlMapper.cs +++ b/Dapper/SqlMapper.cs @@ -632,15 +632,17 @@ private static CacheInfo GetCacheInfo(Identity identity) private static Func GetDeserializer(IDataReader reader, int startBound, int length, bool returnNullIfFirstMissing) { + Type type = typeof(T); #if !CSHARP30 // dynamic is passed in as Object ... by c# design - if (typeof(T) == typeof(object) - || typeof(T) == typeof(FastExpando)) + if (type == typeof(object) + || type == typeof(FastExpando)) { return GetDynamicDeserializer(reader, startBound, length, returnNullIfFirstMissing); } #endif - if (typeof(T).IsClass && typeof(T) != typeof(string)) + + if (type.IsClass && type != typeof(string) && type != typeof(byte[])) { return GetClassDeserializer(reader, startBound, length, returnNullIfFirstMissing); } diff --git a/Tests/Tests.cs b/Tests/Tests.cs index 7a43524..d3b9946 100644 --- a/Tests/Tests.cs +++ b/Tests/Tests.cs @@ -65,7 +65,10 @@ public void SelectListInt() connection.Query("select 1 union all select 2 union all select 3") .IsSequenceEqualTo(new[] { 1, 2, 3 }); } - + public void SelectBinary() + { + connection.Query("select cast(1 as varbinary(4))").First().SequenceEqual(new byte[] {1}); + } public void PassInIntArray() { connection.Query("select * from (select 1 as Id union all select 2 union all select 3) as X where Id in @Ids", new { Ids = new int[] { 1, 2, 3 }.AsEnumerable() }) -- GitLab