Guid fix; IMPORTANT

parent b55cc9a4
...@@ -928,7 +928,8 @@ private static CacheInfo GetCacheInfo(Identity identity) ...@@ -928,7 +928,8 @@ private static CacheInfo GetCacheInfo(Identity identity)
if ( if (
(type.IsClass && type != typeof(string) && type != typeof(byte[]) && type != typeof(System.Data.Linq.Binary)) || (type.IsClass && type != typeof(string) && type != typeof(byte[]) && type != typeof(System.Data.Linq.Binary)) ||
(type.IsValueType && !type.IsPrimitive && !(type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))) (type.IsValueType && !type.IsPrimitive && !(type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
&& type != typeof(Guid))
) )
{ {
return GetTypeDeserializer(type, reader, startBound, length, returnNullIfFirstMissing); return GetTypeDeserializer(type, reader, startBound, length, returnNullIfFirstMissing);
......
...@@ -184,6 +184,7 @@ ...@@ -184,6 +184,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</None> </None>
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\DataSources\SqlMapper.EntityFramework.tempdbEntities1.datasource" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
......
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="tempdbEntities1" Identifier="SqlMapper.EntityFramework.tempdbEntities1" ProviderType="Microsoft.VisualStudio.DataDesign.DataSourceProviders.EntityDataModel.EdmDataSourceProvider" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>SqlMapper.EntityFramework.tempdbEntities1, EntityFramework.Model.Designer.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>
\ No newline at end of file
...@@ -45,7 +45,7 @@ public void SelectListInt() ...@@ -45,7 +45,7 @@ public void SelectListInt()
} }
public void SelectBinary() public void SelectBinary()
{ {
connection.Query<byte[]>("select cast(1 as varbinary(4))").First().SequenceEqual(new byte[] {1}); connection.Query<byte[]>("select cast(1 as varbinary(4))").First().SequenceEqual(new byte[] { 1 });
} }
public void PassInIntArray() public void PassInIntArray()
{ {
...@@ -75,7 +75,7 @@ public void TestSchemaChanged() ...@@ -75,7 +75,7 @@ public void TestSchemaChanged()
public void TestSchemaChangedMultiMap() public void TestSchemaChangedMultiMap()
{ {
connection.Execute("create table #dog(Age int, Name nvarchar(max)) insert #dog values(1, 'Alf')"); connection.Execute("create table #dog(Age int, Name nvarchar(max)) insert #dog values(1, 'Alf')");
var tuple = connection.Query<Dog,Dog,Tuple<Dog, Dog>>("select * from #dog d1 join #dog d2 on 1=1", (d1,d2) => Tuple.Create(d1, d2), splitOn: "Age").Single(); var tuple = connection.Query<Dog, Dog, Tuple<Dog, Dog>>("select * from #dog d1 join #dog d2 on 1=1", (d1, d2) => Tuple.Create(d1, d2), splitOn: "Age").Single();
tuple.Item1.Name.IsEqualTo("Alf"); tuple.Item1.Name.IsEqualTo("Alf");
tuple.Item1.Age.IsEqualTo(1); tuple.Item1.Age.IsEqualTo(1);
...@@ -83,13 +83,13 @@ public void TestSchemaChangedMultiMap() ...@@ -83,13 +83,13 @@ public void TestSchemaChangedMultiMap()
tuple.Item2.Age.IsEqualTo(1); tuple.Item2.Age.IsEqualTo(1);
connection.Execute("alter table #dog drop column Name"); connection.Execute("alter table #dog drop column Name");
tuple = connection.Query<Dog, Dog,Tuple<Dog, Dog>>("select * from #dog d1 join #dog d2 on 1=1", (d1, d2) => Tuple.Create(d1, d2), splitOn: "Age").Single(); tuple = connection.Query<Dog, Dog, Tuple<Dog, Dog>>("select * from #dog d1 join #dog d2 on 1=1", (d1, d2) => Tuple.Create(d1, d2), splitOn: "Age").Single();
tuple.Item1.Name.IsNull(); tuple.Item1.Name.IsNull();
tuple.Item1.Age.IsEqualTo(1); tuple.Item1.Age.IsEqualTo(1);
tuple.Item2.Name.IsNull(); tuple.Item2.Name.IsNull();
tuple.Item2.Age.IsEqualTo(1); tuple.Item2.Age.IsEqualTo(1);
connection.Execute("drop table #dog"); connection.Execute("drop table #dog");
} }
...@@ -240,7 +240,7 @@ public void TestExecuteMultipleCommand() ...@@ -240,7 +240,7 @@ public void TestExecuteMultipleCommand()
class Student class Student
{ {
public string Name {get; set;} public string Name { get; set; }
public int Age { get; set; } public int Age { get; set; }
} }
...@@ -345,7 +345,7 @@ public void TestEnumerationDynamic() ...@@ -345,7 +345,7 @@ public void TestEnumerationDynamic()
public void TestNakedBigInt() public void TestNakedBigInt()
{ {
long foo = 12345; long foo = 12345;
var result = connection.Query<long>("select @foo", new {foo}).Single(); var result = connection.Query<long>("select @foo", new { foo }).Single();
foo.IsEqualTo(result); foo.IsEqualTo(result);
} }
...@@ -355,7 +355,7 @@ public void TestBigIntMember() ...@@ -355,7 +355,7 @@ public void TestBigIntMember()
var result = connection.Query<WithBigInt>(@" var result = connection.Query<WithBigInt>(@"
declare @bar table(Value bigint) declare @bar table(Value bigint)
insert @bar values (@foo) insert @bar values (@foo)
select * from @bar", new {foo}).Single(); select * from @bar", new { foo }).Single();
result.Value.IsEqualTo(foo); result.Value.IsEqualTo(foo);
} }
class WithBigInt class WithBigInt
...@@ -449,7 +449,7 @@ public void TestMultiMapGridReader() ...@@ -449,7 +449,7 @@ public void TestMultiMapGridReader()
data[2].Owner.IsNull(); data[2].Owner.IsNull();
} }
connection.Execute("drop table #Users drop table #Posts"); connection.Execute("drop table #Users drop table #Posts");
} }
...@@ -937,10 +937,12 @@ class WithBizarreData ...@@ -937,10 +937,12 @@ class WithBizarreData
public void TestUnexpectedDataMessage() public void TestUnexpectedDataMessage()
{ {
string msg = null; string msg = null;
try { try
{
connection.Query<int>("select count(1) where 1 = @Foo", new WithBizarreData { Foo = new GenericUriParser(GenericUriParserOptions.Default), Bar = 23 }).First(); connection.Query<int>("select count(1) where 1 = @Foo", new WithBizarreData { Foo = new GenericUriParser(GenericUriParserOptions.Default), Bar = 23 }).First();
} catch(Exception ex) }
catch (Exception ex)
{ {
msg = ex.Message; msg = ex.Message;
} }
...@@ -998,7 +1000,7 @@ public void TestInvalidSplitCausesNiceError() ...@@ -998,7 +1000,7 @@ public void TestInvalidSplitCausesNiceError()
connection.Query<User, User, User>("select 1 A, 2 B, 3 C", (x, y) => x); connection.Query<User, User, User>("select 1 A, 2 B, 3 C", (x, y) => x);
} }
catch (ArgumentException) catch (ArgumentException)
{ {
// expecting an app exception due to multi mapping being bodged // expecting an app exception due to multi mapping being bodged
} }
...@@ -1064,19 +1066,19 @@ public void TestDynamicParamNullSupport() ...@@ -1064,19 +1066,19 @@ public void TestDynamicParamNullSupport()
var p = new DynamicParameters(); var p = new DynamicParameters();
p.Add("@b", dbType: DbType.Int32, direction: ParameterDirection.Output); p.Add("@b", dbType: DbType.Int32, direction: ParameterDirection.Output);
connection.Execute("select @b = null",p); connection.Execute("select @b = null", p);
p.Get<int?>("@b").IsNull(); p.Get<int?>("@b").IsNull();
} }
class Foo1 class Foo1
{ {
public int Id; public int Id;
public int BarId { get; set; } public int BarId { get; set; }
} }
class Bar1 class Bar1
{ {
public int BarId; public int BarId;
public string Name { get; set; } public string Name { get; set; }
} }
public void TestMultiMapperIsNotConfusedWithUnorderedCols() public void TestMultiMapperIsNotConfusedWithUnorderedCols()
{ {
...@@ -1144,7 +1146,7 @@ public void TestAppendingAnonClasses() ...@@ -1144,7 +1146,7 @@ public void TestAppendingAnonClasses()
public void TestAppendingAList() public void TestAppendingAList()
{ {
DynamicParameters p = new DynamicParameters(); DynamicParameters p = new DynamicParameters();
var list = new int[] {1,2,3}; var list = new int[] { 1, 2, 3 };
p.AddDynamicParams(new { list }); p.AddDynamicParams(new { list });
var result = connection.Query<int>("select * from (select 1 A union all select 2 union all select 3) X where A in @list", p).ToList(); var result = connection.Query<int>("select * from (select 1 A union all select 2 union all select 3) X where A in @list", p).ToList();
...@@ -1154,5 +1156,23 @@ public void TestAppendingAList() ...@@ -1154,5 +1156,23 @@ public void TestAppendingAList()
result[2].IsEqualTo(3); result[2].IsEqualTo(3);
} }
public void TestUniqueIdentifier()
{
var guid = Guid.NewGuid();
var result = connection.Query<Guid>("declare @foo uniqueidentifier set @foo = @guid select @foo", new { guid }).Single();
result.IsEqualTo(guid);
}
public void TestNullableUniqueIdentifierNonNull()
{
Guid? guid = Guid.NewGuid();
var result = connection.Query<Guid?>("declare @foo uniqueidentifier set @foo = @guid select @foo", new { guid }).Single();
result.IsEqualTo(guid);
}
public void TestNullableUniqueIdentifierNull()
{
Guid? guid = null;
var result = connection.Query<Guid?>("declare @foo uniqueidentifier set @foo = @guid select @foo", new { guid }).Single();
result.IsEqualTo(guid);
}
} }
} }
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