diff --git a/Dapper/SqlMapper.cs b/Dapper/SqlMapper.cs index 17680cd64f65b1df55c84f819c6c75a504a95a63..277a82ed9034a94522ef47244ca7b5853a8a970f 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 7a435248687371961b72ba60197cf5f4d8fc5346..d3b99465b527053bb27c801f2b49948af9752d3a 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() })