Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
Dapper
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
Dapper
Commits
a8287501
Commit
a8287501
authored
Oct 29, 2011
by
marc.gravell@gmail.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Guid fix; IMPORTANT
parent
b55cc9a4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
19 deletions
+51
-19
SqlMapper.cs
Dapper/SqlMapper.cs
+2
-1
DapperTests.csproj
Tests/DapperTests.csproj
+1
-0
SqlMapper.EntityFramework.tempdbEntities1.datasource
...rces/SqlMapper.EntityFramework.tempdbEntities1.datasource
+10
-0
Tests.cs
Tests/Tests.cs
+38
-18
No files found.
Dapper/SqlMapper.cs
View file @
a8287501
...
@@ -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
);
...
...
Tests/DapperTests.csproj
View file @
a8287501
...
@@ -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>
...
...
Tests/Properties/DataSources/SqlMapper.EntityFramework.tempdbEntities1.datasource
0 → 100644
View file @
a8287501
<?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
Tests/Tests.cs
View file @
a8287501
...
@@ -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
);
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment