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
ec6faf54
Commit
ec6faf54
authored
May 02, 2015
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes for CoreCLR and DNX
parent
a161cb5a
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
332 additions
and
117 deletions
+332
-117
SqlMapper.cs
Dapper NET40/SqlMapper.cs
+13
-13
Program.cs
Dapper.DNX.Tests/Program.cs
+0
-37
project.json
Dapper.DNX.Tests/project.json
+17
-4
project.lock.json
Dapper.DNX.Tests/project.lock.json
+52
-4
Dapper.DNX.sln
Dapper.DNX.sln
+4
-1
project.json
Dapper/project.json
+15
-1
DapperTests NET35.csproj
DapperTests NET35/DapperTests NET35.csproj
+3
-2
DapperTests NET45.csproj
DapperTests NET45/DapperTests NET45.csproj
+2
-2
Assert.cs
Tests/Assert.cs
+4
-0
DapperTests NET40.csproj
Tests/DapperTests NET40.csproj
+3
-2
Program.cs
Tests/Program.cs
+41
-5
Tests.cs
Tests/Tests.cs
+178
-46
No files found.
Dapper NET40/SqlMapper.cs
View file @
ec6faf54
...
@@ -7,16 +7,16 @@
...
@@ -7,16 +7,16 @@
*/
*/
#if DNXCORE50
#if DNXCORE50
using
IDbDataParameter
=
System
.
Data
.
Common
.
DbParameter
;
using
IDbDataParameter
=
global
::
System
.
Data
.
Common
.
DbParameter
;
using
IDataParameter
=
System
.
Data
.
Common
.
DbParameter
;
using
IDataParameter
=
global
::
System
.
Data
.
Common
.
DbParameter
;
using
IDbTransaction
=
System
.
Data
.
Common
.
DbTransaction
;
using
IDbTransaction
=
global
::
System
.
Data
.
Common
.
DbTransaction
;
using
IDbConnection
=
System
.
Data
.
Common
.
DbConnection
;
using
IDbConnection
=
global
::
System
.
Data
.
Common
.
DbConnection
;
using
IDbCommand
=
System
.
Data
.
Common
.
DbCommand
;
using
IDbCommand
=
global
::
System
.
Data
.
Common
.
DbCommand
;
using
IDataReader
=
System
.
Data
.
Common
.
DbDataReader
;
using
IDataReader
=
global
::
System
.
Data
.
Common
.
DbDataReader
;
using
IDataRecord
=
System
.
Data
.
Common
.
DbDataReader
;
using
IDataRecord
=
global
::
System
.
Data
.
Common
.
DbDataReader
;
using
IDataParameterCollection
=
System
.
Data
.
Common
.
DbParameterCollection
;
using
IDataParameterCollection
=
global
::
System
.
Data
.
Common
.
DbParameterCollection
;
using
DataException
=
System
.
InvalidOperationException
;
using
DataException
=
global
::
System
.
InvalidOperationException
;
using
ApplicationException
=
System
.
InvalidOperationException
;
using
ApplicationException
=
global
::
System
.
InvalidOperationException
;
#endif
#endif
using
System
;
using
System
;
...
@@ -4907,10 +4907,10 @@ public DynamicParameters Output<T>(T target, Expression<Func<T, object>> express
...
@@ -4907,10 +4907,10 @@ public DynamicParameters Output<T>(T target, Expression<Func<T, object>> express
#if DNXCORE50
#if DNXCORE50
lock
(
cache
)
lock
(
cache
)
{
{
#endif
if
(!
cache
.
TryGetValue
(
lookup
,
out
setter
))
setter
=
null
;
setter
=
(
Action
<
object
,
DynamicParameters
>)
cache
[
lookup
];
#if DNXCORE50
}
}
#else
setter
=
(
Action
<
object
,
DynamicParameters
>)
cache
[
lookup
];
#endif
#endif
if
(
setter
!=
null
)
goto
MAKECALLBACK
;
if
(
setter
!=
null
)
goto
MAKECALLBACK
;
...
...
Dapper.DNX.Tests/Program.cs
deleted
100644 → 0
View file @
a161cb5a
using
System
;
using
System.Linq
;
using
System.Data.SqlClient
;
using
System.Threading.Tasks
;
using
System.Reflection
;
namespace
Dapper.DNX.Tests
{
public
class
Program
{
public
void
Main
()
{
#if DNXCORE50
Console
.
WriteLine
(
"From: {0}"
,
typeof
(
int
).
AssemblyQualifiedName
);
#else
Console
.
WriteLine
(
"Version: {0}"
,
Environment
.
Version
);
#endif
const
string
connectionString
=
"Data Source=.;Initial Catalog=tempdb;Integrated Security=True"
;
using
(
var
conn
=
new
SqlConnection
(
connectionString
))
{
conn
.
Open
();
var
row
=
conn
.
Query
<
Foo
>(
"select @a as X"
,
new
{
a
=
123
}).
Single
();
Console
.
WriteLine
(
row
.
X
);
var
methods
=
typeof
(
Dapper
.
SqlMapper
).
GetMethods
().
Where
(
x
=>
x
.
Name
==
"QueryAsync"
).
ToList
();
#if ASYNC
row
=
conn
.
QueryAsync
<
Foo
>(
"select @a as X"
,
new
{
a
=
123
}).
Result
.
Single
();
#endif
Console
.
WriteLine
(
row
.
X
);
}
}
class
Foo
{
public
int
X
{
get
;
set
;
}
}
}
}
Dapper.DNX.Tests/project.json
View file @
ec6faf54
...
@@ -6,26 +6,32 @@
...
@@ -6,26 +6,32 @@
"commands"
:
{
"commands"
:
{
"Dapper.DNX.Tests"
:
"Dapper.DNX.Tests"
"Dapper.DNX.Tests"
:
"Dapper.DNX.Tests"
},
},
"compile"
:
[
"../Tests/Tests.cs"
,
"../Tests/Program.cs"
,
"../Tests/Assert.cs"
],
"compilationOptions"
:
{
"define"
:
[
"NOEXTERNALS"
]
},
"frameworks"
:
{
"frameworks"
:
{
"net45"
:
{
"net45"
:
{
"compilationOptions"
:
{
"define"
:
[
"ASYNC"
],
"warningsAsErrors"
:
true
},
"compilationOptions"
:
{
"define"
:
[
"ASYNC"
],
"warningsAsErrors"
:
true
},
"dependencies"
:
{
"dependencies"
:
{
"System.Threading.Thread"
:
"4.0.0-beta-22816"
},
},
"frameworkAssemblies"
:
{
"frameworkAssemblies"
:
{
"System.Data"
:
"4.0.0.0"
"System.Data"
:
"4.0.0.0"
,
"System.Xml"
:
"4.0.0.0"
}
}
},
},
"net40"
:
{
"net40"
:
{
"dependencies"
:
{
"dependencies"
:
{
},
},
"frameworkAssemblies"
:
{
"frameworkAssemblies"
:
{
"System.Data"
:
"4.0.0.0"
"System.Data"
:
"4.0.0.0"
,
"System.Xml"
:
"4.0.0.0"
}
}
},
},
"dnx451"
:
{
"dnx451"
:
{
"compilationOptions"
:
{
"define"
:
[
"ASYNC"
],
"warningsAsErrors"
:
true
},
"compilationOptions"
:
{
"define"
:
[
"ASYNC"
],
"warningsAsErrors"
:
true
},
"frameworkAssemblies"
:
{
"frameworkAssemblies"
:
{
"System.Data"
:
"4.0.0.0"
"System.Data"
:
"4.0.0.0"
,
"System.Xml"
:
"4.0.0.0"
}
}
},
},
...
@@ -33,7 +39,14 @@
...
@@ -33,7 +39,14 @@
"compilationOptions"
:
{
"define"
:
[
],
"warningsAsErrors"
:
true
},
"compilationOptions"
:
{
"define"
:
[
],
"warningsAsErrors"
:
true
},
"dependencies"
:
{
"dependencies"
:
{
"System.Console"
:
"4.0.0-beta-*"
,
"System.Console"
:
"4.0.0-beta-*"
,
"System.Reflection"
:
"4.0.10-beta-*"
"System.Reflection"
:
"4.0.10-beta-*"
,
"System.Linq"
:
"4.0.0-beta-*"
,
"System.Data.Common"
:
"4.0.0-beta-*"
,
"System.Data.SqlClient"
:
"4.0.0-beta-*"
,
"System.Threading"
:
"4.0.10-beta-*"
,
"System.Threading.Thread"
:
"4.0.0-beta-*"
,
"System.Reflection.TypeExtensions"
:
"4.0.0-beta-*"
//
"System.Xml"
:
"4.0.10-beta-*"
}
}
}
}
}
}
...
...
Dapper.DNX.Tests/project.lock.json
View file @
ec6faf54
...
@@ -16,6 +16,20 @@
...
@@ -16,6 +16,20 @@
"runtime"
:
[
"runtime"
:
[
"lib/net45/System.Runtime.dll"
"lib/net45/System.Runtime.dll"
]
]
},
"System.Threading.Thread/4.0.0-beta-22816"
:
{
"dependencies"
:
{
"System.Runtime"
:
"4.0.20-beta-22816"
},
"frameworkAssemblies"
:
[
"mscorlib"
],
"compile"
:
[
"lib/net45/System.Threading.Thread.dll"
],
"runtime"
:
[
"lib/net45/System.Threading.Thread.dll"
]
}
}
},
},
".NETFramework,Version=v4.0"
:
{},
".NETFramework,Version=v4.0"
:
{},
...
@@ -325,6 +339,17 @@
...
@@ -325,6 +339,17 @@
"lib/aspnetcore50/System.Threading.Tasks.dll"
"lib/aspnetcore50/System.Threading.Tasks.dll"
]
]
},
},
"System.Threading.Thread/4.0.0-beta-22816"
:
{
"dependencies"
:
{
"System.Runtime"
:
"4.0.20-beta-22816"
},
"compile"
:
[
"lib/contract/System.Threading.Thread.dll"
],
"runtime"
:
[
"lib/aspnetcore50/System.Threading.Thread.dll"
]
},
"System.Xml.ReaderWriter/4.0.10-beta-22816"
:
{
"System.Xml.ReaderWriter/4.0.10-beta-22816"
:
{
"dependencies"
:
{
"dependencies"
:
{
"System.IO"
:
"4.0.10-beta-22816"
,
"System.IO"
:
"4.0.10-beta-22816"
,
...
@@ -669,6 +694,19 @@
...
@@ -669,6 +694,19 @@
"lib/portable-wpa81+wp80+win80+net45+aspnetcore50/System.Threading.Tasks.dll"
"lib/portable-wpa81+wp80+win80+net45+aspnetcore50/System.Threading.Tasks.dll"
]
]
},
},
"System.Threading.Thread/4.0.0-beta-22816"
:
{
"sha512"
:
"hq1pNoES0jEKslftDhBeJnRUBSjEepiya+39oH/7yCvOp4xMnXHlWe9G7ZS/dg2n4k+3VY21AUifisybcFjcCQ=="
,
"files"
:
[
"License.rtf"
,
"System.Threading.Thread.4.0.0-beta-22816.nupkg"
,
"System.Threading.Thread.4.0.0-beta-22816.nupkg.sha512"
,
"System.Threading.Thread.nuspec"
,
"lib/aspnetcore50/System.Threading.Thread.dll"
,
"lib/contract/System.Threading.Thread.dll"
,
"lib/net45/System.Threading.Thread.dll"
,
"lib/portable-wpa81+wp80+win80+net45+aspnetcore50/System.Threading.Thread.dll"
]
},
"System.Xml.ReaderWriter/4.0.10-beta-22816"
:
{
"System.Xml.ReaderWriter/4.0.10-beta-22816"
:
{
"sha512"
:
"G0aLPtC/phTfiJPwe0VA3tB3x8YFQ1dHFuE1xaHNr9eQm/AfBp4Pk+fn3s7ABJDus/T89EtIHQ9C+O6VmqXIQQ=="
,
"sha512"
:
"G0aLPtC/phTfiJPwe0VA3tB3x8YFQ1dHFuE1xaHNr9eQm/AfBp4Pk+fn3s7ABJDus/T89EtIHQ9C+O6VmqXIQQ=="
,
"files"
:
[
"files"
:
[
...
@@ -688,17 +726,27 @@
...
@@ -688,17 +726,27 @@
"Dapper >= 1.41-*"
"Dapper >= 1.41-*"
],
],
".NETFramework,Version=v4.5"
:
[
".NETFramework,Version=v4.5"
:
[
"framework/System.Data >= 4.0.0.0"
"System.Threading.Thread >= 4.0.0-beta-22816"
,
"framework/System.Data >= 4.0.0.0"
,
"framework/System.Xml >= 4.0.0.0"
],
],
".NETFramework,Version=v4.0"
:
[
".NETFramework,Version=v4.0"
:
[
"framework/System.Data >= 4.0.0.0"
"framework/System.Data >= 4.0.0.0"
,
"framework/System.Xml >= 4.0.0.0"
],
],
"DNX,Version=v4.5.1"
:
[
"DNX,Version=v4.5.1"
:
[
"framework/System.Data >= 4.0.0.0"
"framework/System.Data >= 4.0.0.0"
,
"framework/System.Xml >= 4.0.0.0"
],
],
"DNXCore,Version=v5.0"
:
[
"DNXCore,Version=v5.0"
:
[
"System.Console >= 4.0.0-beta-*"
,
"System.Console >= 4.0.0-beta-*"
,
"System.Reflection >= 4.0.10-beta-*"
"System.Reflection >= 4.0.10-beta-*"
,
"System.Linq >= 4.0.0-beta-*"
,
"System.Data.Common >= 4.0.0-beta-*"
,
"System.Data.SqlClient >= 4.0.0-beta-*"
,
"System.Threading >= 4.0.10-beta-*"
,
"System.Threading.Thread >= 4.0.0-beta-*"
,
"System.Reflection.TypeExtensions >= 4.0.0-beta-*"
]
]
}
}
}
}
\ No newline at end of file
Dapper.DNX.sln
View file @
ec6faf54
Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
# Visual Studio 14
VisualStudioVersion = 14.0.22
728
.1
VisualStudioVersion = 14.0.22
823
.1
MinimumVisualStudioVersion = 10.0.40219.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Dapper", "Dapper\Dapper.xproj", "{088D8CC4-E71E-44B6-9B87-4060B043983D}"
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Dapper", "Dapper\Dapper.xproj", "{088D8CC4-E71E-44B6-9B87-4060B043983D}"
EndProject
EndProject
...
@@ -9,8 +9,11 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Dapper.DNX.Tests", "Dapper.
...
@@ -9,8 +9,11 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Dapper.DNX.Tests", "Dapper.
EndProject
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{03340C6E-4176-4C42-9C76-D5DFC79D1A22}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{03340C6E-4176-4C42-9C76-D5DFC79D1A22}"
ProjectSection(SolutionItems) = preProject
ProjectSection(SolutionItems) = preProject
Tests\Assert.cs = Tests\Assert.cs
Tests\Program.cs = Tests\Program.cs
Dapper NET40\SqlMapper.cs = Dapper NET40\SqlMapper.cs
Dapper NET40\SqlMapper.cs = Dapper NET40\SqlMapper.cs
Dapper NET45\SqlMapperAsync.cs = Dapper NET45\SqlMapperAsync.cs
Dapper NET45\SqlMapperAsync.cs = Dapper NET45\SqlMapperAsync.cs
Tests\Tests.cs = Tests\Tests.cs
EndProjectSection
EndProjectSection
EndProject
EndProject
Global
Global
...
...
Dapper/project.json
View file @
ec6faf54
{
{
"authors"
:
[
"Sam Saffron"
,
"Marc Gravell"
],
"authors"
:
[
"Sam Saffron"
,
"Marc Gravell"
],
"owners"
:
[
"Sam Saffron"
,
"Marc Gravell"
],
"projectUrl"
:
"https://github.com/StackExchange/dapper-dot-net"
,
"licenseUrl"
:
"http://www.apache.org/licenses/LICENSE-2.0"
,
"summary"
:
"A high performance Micro-ORM"
,
"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.."
,
"version"
:
"1.41-beta"
,
"version"
:
"1.41-beta
2
"
,
"compile"
:
[
"../Dapper NET40/*.cs"
,
"../Dapper NET45/*.cs"
],
"compile"
:
[
"../Dapper NET40/*.cs"
,
"../Dapper NET45/*.cs"
],
"title"
:
"Dapper dot net"
,
"tags"
:
[
"orm"
,
"sql"
,
"micro-orm"
],
"frameworks"
:
{
"frameworks"
:
{
"net45"
:
{
"net45"
:
{
"compilationOptions"
:
{
"define"
:
[
"ASYNC"
],
"warningsAsErrors"
:
true
},
"compilationOptions"
:
{
"define"
:
[
"ASYNC"
],
"warningsAsErrors"
:
true
},
...
@@ -21,6 +27,14 @@
...
@@ -21,6 +27,14 @@
"System.Data"
:
"4.0.0.0"
"System.Data"
:
"4.0.0.0"
}
}
},
},
//
"net35"
:
{
//
"compilationOptions"
:
{
"warningsAsErrors"
:
true
,
"languageVersion"
:
"csharp3"
,
"define"
:
[
"CSHARP30"
]
},
//
"dependencies"
:
{
//
},
//
"frameworkAssemblies"
:
{
//
"System.Data"
:
"4.0.0.0"
//
}
//
},
"dnx451"
:
{
"dnx451"
:
{
"compilationOptions"
:
{
"define"
:
[
"ASYNC"
],
"warningsAsErrors"
:
true
},
"compilationOptions"
:
{
"define"
:
[
"ASYNC"
],
"warningsAsErrors"
:
true
},
"dependencies"
:
{
"dependencies"
:
{
...
...
DapperTests NET35/DapperTests NET35.csproj
View file @
ec6faf54
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
<DebugType>
full
</DebugType>
<DebugType>
full
</DebugType>
<Optimize>
false
</Optimize>
<Optimize>
false
</Optimize>
<OutputPath>
bin\Debug\
</OutputPath>
<OutputPath>
bin\Debug\
</OutputPath>
<DefineConstants>
TRACE;DEBUG;NET35
</DefineConstants>
<DefineConstants>
TRACE;DEBUG;NET35
EXTERNALS
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
</PropertyGroup>
...
@@ -30,9 +30,10 @@
...
@@ -30,9 +30,10 @@
<DebugType>
pdbonly
</DebugType>
<DebugType>
pdbonly
</DebugType>
<Optimize>
true
</Optimize>
<Optimize>
true
</Optimize>
<OutputPath>
bin\Release\
</OutputPath>
<OutputPath>
bin\Release\
</OutputPath>
<DefineConstants>
TRACE;NET35
</DefineConstants>
<DefineConstants>
TRACE;NET35
EXTERNALS
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<WarningLevel>
4
</WarningLevel>
<AllowUnsafeBlocks>
true
</AllowUnsafeBlocks>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<Reference
Include=
"System"
/>
<Reference
Include=
"System"
/>
...
...
DapperTests NET45/DapperTests NET45.csproj
View file @
ec6faf54
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
<DebugType>
full
</DebugType>
<DebugType>
full
</DebugType>
<Optimize>
false
</Optimize>
<Optimize>
false
</Optimize>
<OutputPath>
bin\Debug\
</OutputPath>
<OutputPath>
bin\Debug\
</OutputPath>
<DefineConstants>
DEBUG;TRACE
</DefineConstants>
<DefineConstants>
TRACE;DEBUG;EXTERNALS
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
</PropertyGroup>
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
<DebugType>
pdbonly
</DebugType>
<DebugType>
pdbonly
</DebugType>
<Optimize>
true
</Optimize>
<Optimize>
true
</Optimize>
<OutputPath>
bin\Release\
</OutputPath>
<OutputPath>
bin\Release\
</OutputPath>
<DefineConstants>
TRACE
</DefineConstants>
<DefineConstants>
TRACE
;EXTERNALS
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
</PropertyGroup>
...
...
Tests/Assert.cs
View file @
ec6faf54
...
@@ -3,6 +3,10 @@
...
@@ -3,6 +3,10 @@
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
#if DNXCORE50
using
ApplicationException
=
global
::
System
.
InvalidOperationException
;
#endif
namespace
SqlMapper
namespace
SqlMapper
{
{
static
class
Assert
static
class
Assert
...
...
Tests/DapperTests NET40.csproj
View file @
ec6faf54
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
<DebugType>
full
</DebugType>
<DebugType>
full
</DebugType>
<Optimize>
false
</Optimize>
<Optimize>
false
</Optimize>
<OutputPath>
bin\Debug\
</OutputPath>
<OutputPath>
bin\Debug\
</OutputPath>
<DefineConstants>
DEBUG;TRACE
</DefineConstants>
<DefineConstants>
TRACE;DEBUG;EXTERNALS PERF
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<WarningLevel>
4
</WarningLevel>
<Prefer32Bit>
false
</Prefer32Bit>
<Prefer32Bit>
false
</Prefer32Bit>
...
@@ -32,10 +32,11 @@
...
@@ -32,10 +32,11 @@
<DebugType>
pdbonly
</DebugType>
<DebugType>
pdbonly
</DebugType>
<Optimize>
true
</Optimize>
<Optimize>
true
</Optimize>
<OutputPath>
bin\Release\
</OutputPath>
<OutputPath>
bin\Release\
</OutputPath>
<DefineConstants>
TRACE
</DefineConstants>
<DefineConstants>
TRACE
;EXTERNALS PERF
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<WarningLevel>
4
</WarningLevel>
<Prefer32Bit>
false
</Prefer32Bit>
<Prefer32Bit>
false
</Prefer32Bit>
<AllowUnsafeBlocks>
false
</AllowUnsafeBlocks>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<Reference
Include=
"BLToolkit.4"
>
<Reference
Include=
"BLToolkit.4"
>
...
...
Tests/Program.cs
View file @
ec6faf54
...
@@ -6,11 +6,15 @@
...
@@ -6,11 +6,15 @@
namespace
SqlMapper
namespace
SqlMapper
{
{
#if EXTERNALS
[
ServiceStack
.
DataAnnotations
.
Alias
(
"Posts"
)]
[
ServiceStack
.
DataAnnotations
.
Alias
(
"Posts"
)]
[
Soma
.
Core
.
Table
(
Name
=
"Posts"
)]
[
Soma
.
Core
.
Table
(
Name
=
"Posts"
)]
#endif
public
class
Post
public
class
Post
{
{
#if EXTERNALS
[
Soma
.
Core
.
Id
(
Soma
.
Core
.
IdKind
.
Identity
)]
[
Soma
.
Core
.
Id
(
Soma
.
Core
.
IdKind
.
Identity
)]
#endif
public
int
Id
{
get
;
set
;
}
public
int
Id
{
get
;
set
;
}
public
string
Text
{
get
;
set
;
}
public
string
Text
{
get
;
set
;
}
public
DateTime
CreationDate
{
get
;
set
;
}
public
DateTime
CreationDate
{
get
;
set
;
}
...
@@ -42,10 +46,14 @@ public static SqlConnection GetOpenConnection()
...
@@ -42,10 +46,14 @@ public static SqlConnection GetOpenConnection()
static
void
RunPerformanceTests
()
static
void
RunPerformanceTests
()
{
{
#if PERF
var
test
=
new
PerformanceTests
();
var
test
=
new
PerformanceTests
();
const
int
iterations
=
500
;
const
int
iterations
=
500
;
Console
.
WriteLine
(
"Running {0} iterations that load up a post entity"
,
iterations
);
Console
.
WriteLine
(
"Running {0} iterations that load up a post entity"
,
iterations
);
test
.
Run
(
iterations
);
test
.
Run
(
iterations
);
#else
Console
.
WriteLine
(
"Performance tests have not been built; add the PERF symbol"
);
#endif
}
}
static
void
Main
()
static
void
Main
()
...
@@ -57,9 +65,14 @@ static void Main()
...
@@ -57,9 +65,14 @@ static void Main()
EnsureDBSetup
();
EnsureDBSetup
();
RunPerformanceTests
();
RunPerformanceTests
();
#endif
#endif
Console
.
WriteLine
(
"(end of tests; press any key)"
);
#if DNXCORE50
Console
.
WriteLine
(
"(end of tests; press return)"
);
Console
.
ReadLine
();
#else
Console
.
WriteLine
(
"(end of tests; press any key)"
);
Console
.
ReadKey
();
Console
.
ReadKey
();
#endif
}
}
private
static
void
EnsureDBSetup
()
private
static
void
EnsureDBSetup
()
...
@@ -110,27 +123,46 @@ insert Posts ([Text],CreationDate, LastChangeDate) values (replicate('x', 2000),
...
@@ -110,27 +123,46 @@ insert Posts ([Text],CreationDate, LastChangeDate) values (replicate('x', 2000),
cmd
.
ExecuteNonQuery
();
cmd
.
ExecuteNonQuery
();
}
}
}
}
private
static
bool
HasAttribute
<
T
>(
MemberInfo
member
)
where
T
:
Attribute
{
#if DNXCORE50
return
member
.
CustomAttributes
.
Any
(
x
=>
x
.
AttributeType
==
typeof
(
T
));
#else
return
Attribute
.
IsDefined
(
member
,
typeof
(
T
),
true
);
#endif
}
private
static
void
RunTests
()
private
static
void
RunTests
()
{
{
var
tester
=
new
Tests
();
var
tester
=
new
Tests
();
int
fail
=
0
;
int
fail
=
0
,
skip
=
0
,
pass
=
0
;
MethodInfo
[]
methods
=
typeof
(
Tests
).
GetMethods
(
BindingFlags
.
Public
|
BindingFlags
.
Instance
|
BindingFlags
.
DeclaredOnly
);
MethodInfo
[]
methods
=
typeof
(
Tests
).
GetMethods
(
BindingFlags
.
Public
|
BindingFlags
.
Instance
|
BindingFlags
.
DeclaredOnly
);
var
activeTests
=
methods
.
Where
(
m
=>
Attribute
.
IsDefined
(
m
,
typeof
(
ActiveTestAttribute
)
)).
ToArray
();
var
activeTests
=
methods
.
Where
(
m
=>
HasAttribute
<
ActiveTestAttribute
>(
m
)).
ToArray
();
if
(
activeTests
.
Length
!=
0
)
methods
=
activeTests
;
if
(
activeTests
.
Length
!=
0
)
methods
=
activeTests
;
List
<
string
>
failNames
=
new
List
<
string
>();
List
<
string
>
failNames
=
new
List
<
string
>();
foreach
(
var
method
in
methods
)
foreach
(
var
method
in
methods
)
{
{
if
(
HasAttribute
<
SkipTestAttribute
>(
method
))
{
Console
.
Write
(
"Skipping "
+
method
.
Name
);
skip
++;
continue
;
}
Console
.
Write
(
"Running "
+
method
.
Name
);
Console
.
Write
(
"Running "
+
method
.
Name
);
try
try
{
{
method
.
Invoke
(
tester
,
null
);
method
.
Invoke
(
tester
,
null
);
Console
.
WriteLine
(
" - OK!"
);
Console
.
WriteLine
(
" - OK!"
);
pass
++;
}
catch
(
TargetInvocationException
tie
)
}
catch
(
TargetInvocationException
tie
)
{
{
fail
++;
fail
++;
Console
.
WriteLine
(
" - "
+
tie
.
InnerException
.
Message
);
Console
.
WriteLine
(
" - "
+
tie
.
InnerException
.
Message
);
failNames
.
Add
(
method
.
Name
);
failNames
.
Add
(
method
.
Name
);
if
(
tie
.
InnerException
is
TypeInitializationException
)
{
Console
.
WriteLine
(
"> "
+
tie
.
InnerException
.
InnerException
.
Message
);
}
}
catch
(
Exception
ex
)
}
catch
(
Exception
ex
)
{
{
...
@@ -139,13 +171,15 @@ private static void RunTests()
...
@@ -139,13 +171,15 @@ private static void RunTests()
}
}
}
}
Console
.
WriteLine
();
Console
.
WriteLine
();
Console
.
WriteLine
(
"Passed: {0}, Failed: {1}, Skipped: {2}"
,
pass
,
fail
,
skip
);
if
(
fail
==
0
)
if
(
fail
==
0
)
{
{
Console
.
WriteLine
(
"(all tests successful)"
);
Console
.
WriteLine
(
"(all tests successful)"
);
}
}
else
else
{
{
Console
.
WriteLine
(
"
#### FAILED: {0}"
,
fail
);
Console
.
WriteLine
(
"
Failures:"
);
foreach
(
var
failName
in
failNames
)
foreach
(
var
failName
in
failNames
)
{
{
Console
.
WriteLine
(
failName
);
Console
.
WriteLine
(
failName
);
...
@@ -156,5 +190,7 @@ private static void RunTests()
...
@@ -156,5 +190,7 @@ private static void RunTests()
[
AttributeUsage
(
AttributeTargets
.
Method
,
AllowMultiple
=
false
)]
[
AttributeUsage
(
AttributeTargets
.
Method
,
AllowMultiple
=
false
)]
public
sealed
class
ActiveTestAttribute
:
Attribute
{}
public
sealed
class
ActiveTestAttribute
:
Attribute
{}
[
AttributeUsage
(
AttributeTargets
.
Method
,
AllowMultiple
=
false
)]
public
sealed
class
SkipTestAttribute
:
Attribute
{
}
}
}
Tests/Tests.cs
View file @
ec6faf54
//#define POSTGRESQL // uncomment to run postgres tests
//#define POSTGRESQL // uncomment to run postgres tests
#if DNXCORE50
using
IDbCommand
=
global
::
System
.
Data
.
Common
.
DbCommand
;
using
IDbDataParameter
=
global
::
System
.
Data
.
Common
.
DbParameter
;
using
IDbConnection
=
global
::
System
.
Data
.
Common
.
DbConnection
;
using
IDbTransaction
=
global
::
System
.
Data
.
Common
.
DbTransaction
;
using
IDataReader
=
global
::
System
.
Data
.
Common
.
DbDataReader
;
#endif
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Data.SqlClient
;
using
System.Data.SqlClient
;
using
System.Linq
;
using
System.Linq
;
using
Dapper
;
using
Dapper
;
using
System.Data.SqlServerCe
;
using
System.IO
;
using
System.IO
;
using
System.Data
;
using
System.Data
;
using
System.Collections
;
using
System.Collections
;
...
@@ -15,14 +23,46 @@
...
@@ -15,14 +23,46 @@
using
System.Data.Common
;
using
System.Data.Common
;
using
System.Globalization
;
using
System.Globalization
;
using
System.Threading
;
using
System.Threading
;
using
System.Data.Entity.Spatial
;
using
Microsoft.SqlServer.Types
;
using
System.Data.SqlTypes
;
using
System.Data.SqlTypes
;
using
FirebirdSql.Data.FirebirdClient
;
using
System.Diagnostics
;
using
System.Diagnostics
;
#if EXTERNALS
using
FirebirdSql.Data.FirebirdClient
;
using
System.Data.Entity.Spatial
;
using
Microsoft.SqlServer.Types
;
using
System.Data.SqlServerCe
;
#if POSTGRESQL
#if POSTGRESQL
using
Npgsql
;
using
Npgsql
;
#endif
#endif
#endif
#if DNXCORE50
namespace
System.ComponentModel
{
public
sealed
class
DescriptionAttribute
:
Attribute
{
public
DescriptionAttribute
(
string
description
)
{
Description
=
description
;
}
public
string
Description
{
get
;
private
set
;}
}
}
namespace
System
{
public
enum
GenericUriParserOptions
{
Default
}
public
class
GenericUriParser
{
private
GenericUriParserOptions
options
;
public
GenericUriParser
(
GenericUriParserOptions
options
)
{
this
.
options
=
options
;
}
}
}
#endif
namespace
SqlMapper
namespace
SqlMapper
{
{
...
@@ -222,7 +262,7 @@ public void TestNoDefaultConstructorWithEnum()
...
@@ -222,7 +262,7 @@ public void TestNoDefaultConstructorWithEnum()
nodef
.
NE1
.
IsEqualTo
(
ShortEnum
.
Five
);
nodef
.
NE1
.
IsEqualTo
(
ShortEnum
.
Five
);
nodef
.
NE2
.
IsEqualTo
(
null
);
nodef
.
NE2
.
IsEqualTo
(
null
);
}
}
#if EXTERNALS
class
NoDefaultConstructorWithBinary
class
NoDefaultConstructorWithBinary
{
{
public
System
.
Data
.
Linq
.
Binary
Value
{
get
;
set
;
}
public
System
.
Data
.
Linq
.
Binary
Value
{
get
;
set
;
}
...
@@ -232,7 +272,6 @@ public NoDefaultConstructorWithBinary(System.Data.Linq.Binary val)
...
@@ -232,7 +272,6 @@ public NoDefaultConstructorWithBinary(System.Data.Linq.Binary val)
Value
=
val
;
Value
=
val
;
}
}
}
}
public
void
TestNoDefaultConstructorBinary
()
public
void
TestNoDefaultConstructorBinary
()
{
{
byte
[]
orig
=
new
byte
[
20
];
byte
[]
orig
=
new
byte
[
20
];
...
@@ -241,7 +280,7 @@ public void TestNoDefaultConstructorBinary()
...
@@ -241,7 +280,7 @@ public void TestNoDefaultConstructorBinary()
var
output
=
connection
.
Query
<
NoDefaultConstructorWithBinary
>(
"select @input as val"
,
new
{
input
}).
First
().
Value
;
var
output
=
connection
.
Query
<
NoDefaultConstructorWithBinary
>(
"select @input as val"
,
new
{
input
}).
First
().
Value
;
output
.
ToArray
().
IsSequenceEqualTo
(
orig
);
output
.
ToArray
().
IsSequenceEqualTo
(
orig
);
}
}
#endif
// http://stackoverflow.com/q/8593871
// http://stackoverflow.com/q/8593871
public
void
TestAbstractInheritance
()
public
void
TestAbstractInheritance
()
{
{
...
@@ -515,7 +554,7 @@ public void TestExtraFields()
...
@@ -515,7 +554,7 @@ public void TestExtraFields()
dog
.
First
().
Id
dog
.
First
().
Id
.
IsEqualTo
(
guid
);
.
IsEqualTo
(
guid
);
}
}
#if EXTERNALS
// see http://stackoverflow.com/q/18847510/23354
// see http://stackoverflow.com/q/18847510/23354
public
void
TestOleDbParameters
()
public
void
TestOleDbParameters
()
{
{
...
@@ -537,7 +576,7 @@ System.Data.OleDb.OleDbConnection ConnectViaOledb()
...
@@ -537,7 +576,7 @@ System.Data.OleDb.OleDbConnection ConnectViaOledb()
conn
.
Open
();
conn
.
Open
();
return
conn
;
return
conn
;
}
}
#endif
public
void
TestStrongType
()
public
void
TestStrongType
()
{
{
var
guid
=
Guid
.
NewGuid
();
var
guid
=
Guid
.
NewGuid
();
...
@@ -1109,7 +1148,7 @@ public void TestFieldsAndPrivates()
...
@@ -1109,7 +1148,7 @@ public void TestFieldsAndPrivates()
}
}
#if EXTERNALS
public
void
ExecuteReader
()
public
void
ExecuteReader
()
{
{
var
dt
=
new
DataTable
();
var
dt
=
new
DataTable
();
...
@@ -1121,7 +1160,7 @@ public void ExecuteReader()
...
@@ -1121,7 +1160,7 @@ public void ExecuteReader()
((
int
)
dt
.
Rows
[
0
][
0
]).
IsEqualTo
(
3
);
((
int
)
dt
.
Rows
[
0
][
0
]).
IsEqualTo
(
3
);
((
int
)
dt
.
Rows
[
0
][
1
]).
IsEqualTo
(
4
);
((
int
)
dt
.
Rows
[
0
][
1
]).
IsEqualTo
(
4
);
}
}
#endif
private
class
TestFieldCaseAndPrivatesEntity
private
class
TestFieldCaseAndPrivatesEntity
{
{
public
int
a
{
get
;
set
;
}
public
int
a
{
get
;
set
;
}
...
@@ -1235,7 +1274,7 @@ public class AuthorCE
...
@@ -1235,7 +1274,7 @@ public class AuthorCE
public
int
ID
{
get
;
set
;
}
public
int
ID
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
}
}
#if EXTERNALS
public
void
MultiRSSqlCE
()
public
void
MultiRSSqlCE
()
{
{
if
(
File
.
Exists
(
"Test.sdf"
))
if
(
File
.
Exists
(
"Test.sdf"
))
...
@@ -1264,7 +1303,7 @@ public void MultiRSSqlCE()
...
@@ -1264,7 +1303,7 @@ public void MultiRSSqlCE()
cnn
.
Close
();
cnn
.
Close
();
}
}
}
}
#endif
enum
TestEnum
:
byte
enum
TestEnum
:
byte
{
{
Bla
=
1
Bla
=
1
...
@@ -1656,7 +1695,7 @@ public void AddParameters(IDbCommand command, Dapper.SqlMapper.Identity identity
...
@@ -1656,7 +1695,7 @@ public void AddParameters(IDbCommand command, Dapper.SqlMapper.Identity identity
}
}
}
}
#if EXTERNALS
// SQL Server specific test to demonstrate TVP
// SQL Server specific test to demonstrate TVP
public
void
TestTVP
()
public
void
TestTVP
()
{
{
...
@@ -1755,7 +1794,7 @@ public void TestTVPWithAdditionalParams()
...
@@ -1755,7 +1794,7 @@ public void TestTVPWithAdditionalParams()
}
}
}
}
}
}
#endif
class
IntCustomParam
:
Dapper
.
SqlMapper
.
ICustomQueryParameter
class
IntCustomParam
:
Dapper
.
SqlMapper
.
ICustomQueryParameter
{
{
IEnumerable
<
int
>
numbers
;
IEnumerable
<
int
>
numbers
;
...
@@ -1789,7 +1828,7 @@ public void AddParameter(IDbCommand command, string name)
...
@@ -1789,7 +1828,7 @@ public void AddParameter(IDbCommand command, string name)
p
.
Value
=
number_list
;
p
.
Value
=
number_list
;
}
}
}
}
#if EXTERNALS
public
void
TestTVPWithAnonymousObject
()
public
void
TestTVPWithAnonymousObject
()
{
{
try
try
...
@@ -1816,6 +1855,7 @@ public void TestTVPWithAnonymousObject()
...
@@ -1816,6 +1855,7 @@ public void TestTVPWithAnonymousObject()
}
}
}
}
}
}
#endif
class
Parent
class
Parent
{
{
...
@@ -1864,6 +1904,7 @@ class WithBizarreData
...
@@ -1864,6 +1904,7 @@ class WithBizarreData
public
GenericUriParser
Foo
{
get
;
set
;
}
public
GenericUriParser
Foo
{
get
;
set
;
}
public
int
Bar
{
get
;
set
;
}
public
int
Bar
{
get
;
set
;
}
}
}
public
void
TestUnexpectedDataMessage
()
public
void
TestUnexpectedDataMessage
()
{
{
string
msg
=
null
;
string
msg
=
null
;
...
@@ -1878,6 +1919,7 @@ public void TestUnexpectedDataMessage()
...
@@ -1878,6 +1919,7 @@ public void TestUnexpectedDataMessage()
}
}
msg
.
IsEqualTo
(
"The member Foo of type System.GenericUriParser cannot be used as a parameter value"
);
msg
.
IsEqualTo
(
"The member Foo of type System.GenericUriParser cannot be used as a parameter value"
);
}
}
public
void
TestUnexpectedButFilteredDataMessage
()
public
void
TestUnexpectedButFilteredDataMessage
()
{
{
int
i
=
connection
.
Query
<
int
>(
"select @Bar"
,
new
WithBizarreData
{
Foo
=
new
GenericUriParser
(
GenericUriParserOptions
.
Default
),
Bar
=
23
}).
Single
();
int
i
=
connection
.
Query
<
int
>(
"select @Bar"
,
new
WithBizarreData
{
Foo
=
new
GenericUriParser
(
GenericUriParserOptions
.
Default
),
Bar
=
23
}).
Single
();
...
@@ -2094,6 +2136,8 @@ public void TestMultiMapperIsNotConfusedWithUnorderedCols()
...
@@ -2094,6 +2136,8 @@ public void TestMultiMapperIsNotConfusedWithUnorderedCols()
result
.
Item2
.
BarId
.
IsEqualTo
(
3
);
result
.
Item2
.
BarId
.
IsEqualTo
(
3
);
result
.
Item2
.
Name
.
IsEqualTo
(
"a"
);
result
.
Item2
.
Name
.
IsEqualTo
(
"a"
);
}
}
#if EXTERNALS
public
void
TestLinqBinaryToClass
()
public
void
TestLinqBinaryToClass
()
{
{
byte
[]
orig
=
new
byte
[
20
];
byte
[]
orig
=
new
byte
[
20
];
...
@@ -2120,7 +2164,7 @@ class WithBinary
...
@@ -2120,7 +2164,7 @@ class WithBinary
{
{
public
System
.
Data
.
Linq
.
Binary
Value
{
get
;
set
;
}
public
System
.
Data
.
Linq
.
Binary
Value
{
get
;
set
;
}
}
}
#endif
class
WithPrivateConstructor
class
WithPrivateConstructor
{
{
...
@@ -2489,7 +2533,7 @@ public void TestCustomTypeMap()
...
@@ -2489,7 +2533,7 @@ public void TestCustomTypeMap()
// custom mapping
// custom mapping
var
map
=
new
CustomPropertyTypeMap
(
typeof
(
TypeWithMapping
),
var
map
=
new
CustomPropertyTypeMap
(
typeof
(
TypeWithMapping
),
(
type
,
columnName
)
=>
type
.
GetProperties
().
Where
(
prop
=>
prop
.
GetCustomAttributes
(
false
).
OfType
<
DescriptionAttribute
>().
Any
(
attr
=>
attr
.
Description
==
columnName
)
).
FirstOrDefault
());
(
type
,
columnName
)
=>
type
.
GetProperties
().
Where
(
prop
=>
GetDescriptionFromAttribute
(
prop
)
==
columnName
).
FirstOrDefault
());
Dapper
.
SqlMapper
.
SetTypeMap
(
typeof
(
TypeWithMapping
),
map
);
Dapper
.
SqlMapper
.
SetTypeMap
(
typeof
(
TypeWithMapping
),
map
);
item
=
connection
.
Query
<
TypeWithMapping
>(
"Select 'AVal' as A, 'BVal' as B"
).
Single
();
item
=
connection
.
Query
<
TypeWithMapping
>(
"Select 'AVal' as A, 'BVal' as B"
).
Single
();
...
@@ -2502,7 +2546,17 @@ public void TestCustomTypeMap()
...
@@ -2502,7 +2546,17 @@ public void TestCustomTypeMap()
item
.
A
.
IsEqualTo
(
"AVal"
);
item
.
A
.
IsEqualTo
(
"AVal"
);
item
.
B
.
IsEqualTo
(
"BVal"
);
item
.
B
.
IsEqualTo
(
"BVal"
);
}
}
static
string
GetDescriptionFromAttribute
(
MemberInfo
member
)
{
if
(
member
==
null
)
return
null
;
#if DNXCORE50
var
data
=
member
.
CustomAttributes
.
FirstOrDefault
(
x
=>
x
.
AttributeType
==
typeof
(
DescriptionAttribute
));
return
data
==
null
?
null
:
(
string
)
data
.
ConstructorArguments
.
Single
().
Value
;
#else
var
attrib
=
(
DescriptionAttribute
)
Attribute
.
GetCustomAttribute
(
member
,
typeof
(
DescriptionAttribute
),
false
);
return
attrib
==
null
?
null
:
attrib
.
Description
;
#endif
}
public
class
TypeWithMapping
public
class
TypeWithMapping
{
{
[
Description
(
"B"
)]
[
Description
(
"B"
)]
...
@@ -2872,7 +2926,70 @@ public void TestChangingDefaultStringTypeMappingToAnsiString()
...
@@ -2872,7 +2926,70 @@ public void TestChangingDefaultStringTypeMappingToAnsiString()
Dapper
.
SqlMapper
.
PurgeQueryCache
();
Dapper
.
SqlMapper
.
PurgeQueryCache
();
Dapper
.
SqlMapper
.
AddTypeMap
(
typeof
(
string
),
DbType
.
String
);
// Restore Default to Unicode String
Dapper
.
SqlMapper
.
AddTypeMap
(
typeof
(
string
),
DbType
.
String
);
// Restore Default to Unicode String
}
}
#if DNXCORE50
class
TransactedConnection
:
IDbConnection
{
IDbConnection
_conn
;
IDbTransaction
_tran
;
public
TransactedConnection
(
IDbConnection
conn
,
IDbTransaction
tran
)
{
_conn
=
conn
;
_tran
=
tran
;
}
public
override
string
ConnectionString
{
get
{
return
_conn
.
ConnectionString
;
}
set
{
_conn
.
ConnectionString
=
value
;
}
}
public
override
int
ConnectionTimeout
{
get
{
return
_conn
.
ConnectionTimeout
;
}
}
public
override
string
Database
{
get
{
return
_conn
.
Database
;
}
}
public
override
ConnectionState
State
{
get
{
return
_conn
.
State
;
}
}
protected
override
IDbTransaction
BeginDbTransaction
(
IsolationLevel
isolationLevel
)
{
return
_tran
;
}
public
override
void
ChangeDatabase
(
string
databaseName
)
{
_conn
.
ChangeDatabase
(
databaseName
);
}
public
override
string
DataSource
{
get
{
return
_conn
.
DataSource
;
}
}
public
override
string
ServerVersion
{
get
{
return
_conn
.
ServerVersion
;
}
}
public
override
void
Close
()
{
_conn
.
Close
();
}
protected
override
IDbCommand
CreateDbCommand
()
{
// The command inherits the "current" transaction.
var
command
=
_conn
.
CreateCommand
();
command
.
Transaction
=
_tran
;
return
command
;
}
protected
override
void
Dispose
(
bool
disposing
)
{
if
(
disposing
)
_conn
.
Dispose
();
base
.
Dispose
(
disposing
);
}
public
override
void
Open
()
{
_conn
.
Open
();
}
}
#else
class
TransactedConnection
:
IDbConnection
class
TransactedConnection
:
IDbConnection
{
{
IDbConnection
_conn
;
IDbConnection
_conn
;
...
@@ -2927,7 +3044,7 @@ public void Open()
...
@@ -2927,7 +3044,7 @@ public void Open()
_conn
.
Open
();
_conn
.
Open
();
}
}
}
}
#endif
public
void
TestDapperTableMetadataRetrieval
()
public
void
TestDapperTableMetadataRetrieval
()
{
{
// Test for a bug found in CS 51509960 where the following sequence would result in an InvalidOperationException being
// Test for a bug found in CS 51509960 where the following sequence would result in an InvalidOperationException being
...
@@ -3004,20 +3121,29 @@ public void TestDoubleDecimalConversions_SO18228523_Nulls()
...
@@ -3004,20 +3121,29 @@ public void TestDoubleDecimalConversions_SO18228523_Nulls()
row
.
C
.
Equals
(
0.0
M
);
row
.
C
.
Equals
(
0.0
M
);
row
.
D
.
IsNull
();
row
.
D
.
IsNull
();
}
}
private
static
CultureInfo
ActiveCulture
{
#if DNXCORE50
get
{
return
CultureInfo
.
CurrentCulture
;
}
set
{
CultureInfo
.
CurrentCulture
=
value
;
}
#else
get
{
return
Thread
.
CurrentThread
.
CurrentCulture
;
}
set
{
Thread
.
CurrentThread
.
CurrentCulture
=
value
;
}
#endif
}
public
void
TestParameterInclusionNotSensitiveToCurrentCulture
()
public
void
TestParameterInclusionNotSensitiveToCurrentCulture
()
{
{
// note this might fail if your database server is case-sensitive
// note this might fail if your database server is case-sensitive
CultureInfo
current
=
Thread
.
CurrentThread
.
Current
Culture
;
CultureInfo
current
=
Active
Culture
;
try
try
{
{
Thread
.
CurrentThread
.
Current
Culture
=
new
CultureInfo
(
"tr-TR"
);
Active
Culture
=
new
CultureInfo
(
"tr-TR"
);
connection
.
Query
<
int
>(
"select @pid"
,
new
{
PId
=
1
}).
Single
();
connection
.
Query
<
int
>(
"select @pid"
,
new
{
PId
=
1
}).
Single
();
}
}
finally
finally
{
{
Thread
.
CurrentThread
.
Current
Culture
=
current
;
Active
Culture
=
current
;
}
}
}
}
public
void
LiteralReplacement
()
public
void
LiteralReplacement
()
...
@@ -3173,7 +3299,7 @@ class HasDoubleDecimal
...
@@ -3173,7 +3299,7 @@ class HasDoubleDecimal
public
decimal
C
{
get
;
set
;
}
public
decimal
C
{
get
;
set
;
}
public
decimal
?
D
{
get
;
set
;
}
public
decimal
?
D
{
get
;
set
;
}
}
}
#if EXTERNALS
public
void
DataTableParameters
()
public
void
DataTableParameters
()
{
{
try
{
connection
.
Execute
(
"drop proc #DataTableParameters"
);
}
try
{
connection
.
Execute
(
"drop proc #DataTableParameters"
);
}
...
@@ -3277,7 +3403,7 @@ public void SupportInit()
...
@@ -3277,7 +3403,7 @@ public void SupportInit()
obj
.
Value
.
Equals
(
"abc"
);
obj
.
Value
.
Equals
(
"abc"
);
obj
.
Flags
.
Equals
(
31
);
obj
.
Flags
.
Equals
(
31
);
}
}
#endif
public
void
GuidIn_SO_24177902
()
public
void
GuidIn_SO_24177902
()
{
{
// invent and populate
// invent and populate
...
@@ -3304,7 +3430,7 @@ public void GuidIn_SO_24177902()
...
@@ -3304,7 +3430,7 @@ public void GuidIn_SO_24177902()
rows
[
1
].
i
.
Equals
(
3
);
rows
[
1
].
i
.
Equals
(
3
);
rows
[
1
].
g
.
Equals
(
c
);
rows
[
1
].
g
.
Equals
(
c
);
}
}
#if EXTERNALS
class
HazGeo
class
HazGeo
{
{
public
int
Id
{
get
;
set
;
}
public
int
Id
{
get
;
set
;
}
...
@@ -3372,7 +3498,7 @@ public class HazSqlHierarchy
...
@@ -3372,7 +3498,7 @@ public class HazSqlHierarchy
public
int
Id
{
get
;
set
;
}
public
int
Id
{
get
;
set
;
}
public
SqlHierarchyId
Path
{
get
;
set
;
}
public
SqlHierarchyId
Path
{
get
;
set
;
}
}
}
#endif
public
void
TypeBasedViaDynamic
()
public
void
TypeBasedViaDynamic
()
{
{
Type
type
=
GetSomeType
();
Type
type
=
GetSomeType
();
...
@@ -3432,7 +3558,7 @@ public class SomeType
...
@@ -3432,7 +3558,7 @@ public class SomeType
public
int
A
{
get
;
set
;
}
public
int
A
{
get
;
set
;
}
public
string
B
{
get
;
set
;
}
public
string
B
{
get
;
set
;
}
}
}
#if !DNXCORE50
class
WithInit
:
ISupportInitialize
class
WithInit
:
ISupportInitialize
{
{
public
string
Value
{
get
;
set
;
}
public
string
Value
{
get
;
set
;
}
...
@@ -3448,7 +3574,7 @@ void ISupportInitialize.EndInit()
...
@@ -3448,7 +3574,7 @@ void ISupportInitialize.EndInit()
Flags
+=
30
;
Flags
+=
30
;
}
}
}
}
#endif
public
void
SO24607639_NullableBools
()
public
void
SO24607639_NullableBools
()
{
{
var
obj
=
connection
.
Query
<
HazBools
>(
var
obj
=
connection
.
Query
<
HazBools
>(
...
@@ -3482,7 +3608,9 @@ public void SO24605346_ProcsAndStrings()
...
@@ -3482,7 +3608,9 @@ public void SO24605346_ProcsAndStrings()
class
PracticeRebateOrders
class
PracticeRebateOrders
{
{
public
string
fTaxInvoiceNumber
;
public
string
fTaxInvoiceNumber
;
#if EXTERNALS
[
System
.
Xml
.
Serialization
.
XmlElementAttribute
(
Form
=
System
.
Xml
.
Schema
.
XmlSchemaForm
.
Unqualified
)]
[
System
.
Xml
.
Serialization
.
XmlElementAttribute
(
Form
=
System
.
Xml
.
Schema
.
XmlSchemaForm
.
Unqualified
)]
#endif
public
string
TaxInvoiceNumber
{
get
{
return
fTaxInvoiceNumber
;
}
set
{
fTaxInvoiceNumber
=
value
;
}
}
public
string
TaxInvoiceNumber
{
get
{
return
fTaxInvoiceNumber
;
}
set
{
fTaxInvoiceNumber
=
value
;
}
}
}
}
...
@@ -3498,7 +3626,7 @@ public override RatingValue Parse(object value)
...
@@ -3498,7 +3626,7 @@ public override RatingValue Parse(object value)
throw
new
FormatException
(
"Invalid conversion to RatingValue"
);
throw
new
FormatException
(
"Invalid conversion to RatingValue"
);
}
}
public
override
void
SetValue
(
System
.
Data
.
IDbDataParameter
parameter
,
RatingValue
value
)
public
override
void
SetValue
(
IDbDataParameter
parameter
,
RatingValue
value
)
{
{
// ... null, range checks etc ...
// ... null, range checks etc ...
parameter
.
DbType
=
System
.
Data
.
DbType
.
Int32
;
parameter
.
DbType
=
System
.
Data
.
DbType
.
Int32
;
...
@@ -3566,10 +3694,12 @@ public void Issue22_ExecuteScalar()
...
@@ -3566,10 +3694,12 @@ public void Issue22_ExecuteScalar()
int
?
k
=
connection
.
ExecuteScalar
<
int
?>(
"select @i"
,
new
{
i
=
default
(
int
?)
});
int
?
k
=
connection
.
ExecuteScalar
<
int
?>(
"select @i"
,
new
{
i
=
default
(
int
?)
});
k
.
IsNull
();
k
.
IsNull
();
#if EXTERNALS
Dapper
.
EntityFramework
.
Handlers
.
Register
();
Dapper
.
EntityFramework
.
Handlers
.
Register
();
var
geo
=
DbGeography
.
LineFromText
(
"LINESTRING(-122.360 47.656, -122.343 47.656 )"
,
4326
);
var
geo
=
DbGeography
.
LineFromText
(
"LINESTRING(-122.360 47.656, -122.343 47.656 )"
,
4326
);
var
geo2
=
connection
.
ExecuteScalar
<
DbGeography
>(
"select @geo"
,
new
{
geo
});
var
geo2
=
connection
.
ExecuteScalar
<
DbGeography
>(
"select @geo"
,
new
{
geo
});
geo2
.
IsNotNull
();
geo2
.
IsNotNull
();
#endif
}
}
public
void
Issue142_FailsNamedStatus
()
public
void
Issue142_FailsNamedStatus
()
...
@@ -3955,7 +4085,7 @@ public void Issue178_SqlServer()
...
@@ -3955,7 +4085,7 @@ public void Issue178_SqlServer()
Assert
.
IsFalse
(
reader2
.
NextResult
());
Assert
.
IsFalse
(
reader2
.
NextResult
());
}
}
}
}
#if EXTERNALS
public
void
Issue178_Firebird
()
// we expect this to fail due to a bug in Firebird; a PR to fix it has been submitted
public
void
Issue178_Firebird
()
// we expect this to fail due to a bug in Firebird; a PR to fix it has been submitted
{
{
var
cs
=
@"initial catalog=localhost:database;user id=SYSDBA;password=masterkey"
;
var
cs
=
@"initial catalog=localhost:database;user id=SYSDBA;password=masterkey"
;
...
@@ -4000,6 +4130,7 @@ public void PseudoPositionalParameters_Simple()
...
@@ -4000,6 +4130,7 @@ public void PseudoPositionalParameters_Simple()
value
.
IsEqualTo
(
9
);
value
.
IsEqualTo
(
9
);
}
}
}
}
public
void
PseudoPositionalParameters_Dynamic
()
public
void
PseudoPositionalParameters_Dynamic
()
{
{
using
(
var
connection
=
ConnectViaOledb
())
using
(
var
connection
=
ConnectViaOledb
())
...
@@ -4013,6 +4144,7 @@ public void PseudoPositionalParameters_Dynamic()
...
@@ -4013,6 +4144,7 @@ public void PseudoPositionalParameters_Dynamic()
value
.
IsEqualTo
(
9
);
value
.
IsEqualTo
(
9
);
}
}
}
}
public
void
PseudoPositionalParameters_ReusedParameter
()
public
void
PseudoPositionalParameters_ReusedParameter
()
{
{
using
(
var
connection
=
ConnectViaOledb
())
using
(
var
connection
=
ConnectViaOledb
())
...
@@ -4058,7 +4190,7 @@ public void PseudoPositionalParameters_ExecMulti()
...
@@ -4058,7 +4190,7 @@ public void PseudoPositionalParameters_ExecMulti()
sum
.
IsEqualTo
(
10
);
sum
.
IsEqualTo
(
10
);
}
}
}
}
#endif
public
void
QueryBasicWithoutQuery
()
public
void
QueryBasicWithoutQuery
()
{
{
int
?
i
=
connection
.
Query
<
int
?>(
"print 'not a query'"
).
FirstOrDefault
();
int
?
i
=
connection
.
Query
<
int
?>(
"print 'not a query'"
).
FirstOrDefault
();
...
@@ -4210,7 +4342,7 @@ public void BasicDecimals()
...
@@ -4210,7 +4342,7 @@ public void BasicDecimals()
var
c
=
connection
.
Query
<
decimal
>(
"select @c"
,
new
{
c
=
11.884
M
}).
Single
();
var
c
=
connection
.
Query
<
decimal
>(
"select @c"
,
new
{
c
=
11.884
M
}).
Single
();
c
.
IsEqualTo
(
11.884
M
);
c
.
IsEqualTo
(
11.884
M
);
}
}
[
SkipTest
]
public
void
Issue263_Timeout
()
public
void
Issue263_Timeout
()
{
{
var
watch
=
Stopwatch
.
StartNew
();
var
watch
=
Stopwatch
.
StartNew
();
...
@@ -4220,7 +4352,7 @@ public void Issue263_Timeout()
...
@@ -4220,7 +4352,7 @@ public void Issue263_Timeout()
var
minutes
=
watch
.
ElapsedMilliseconds
/
1000
/
60
;
var
minutes
=
watch
.
ElapsedMilliseconds
/
1000
/
60
;
Assert
.
IsTrue
(
minutes
>=
0.95
&&
minutes
<=
1.05
);
Assert
.
IsTrue
(
minutes
>=
0.95
&&
minutes
<=
1.05
);
}
}
#if EXTERNALS
public
void
SO29596645_TvpProperty
()
public
void
SO29596645_TvpProperty
()
{
{
try
{
connection
.
Execute
(
"CREATE TYPE SO29596645_ReminderRuleType AS TABLE (id int NOT NULL)"
);
}
try
{
connection
.
Execute
(
"CREATE TYPE SO29596645_ReminderRuleType AS TABLE (id int NOT NULL)"
);
}
...
@@ -4234,7 +4366,7 @@ public void SO29596645_TvpProperty()
...
@@ -4234,7 +4366,7 @@ public void SO29596645_TvpProperty()
val
.
IsEqualTo
(
20
);
val
.
IsEqualTo
(
20
);
}
}
#endif
public
void
Issue268_ReturnQueryMultiple
()
public
void
Issue268_ReturnQueryMultiple
()
{
{
connection
.
Execute
(
@"create proc #TestProc268 (@a int, @b int, @c int)as
connection
.
Execute
(
@"create proc #TestProc268 (@a int, @b int, @c int)as
...
@@ -4257,7 +4389,7 @@ select @b
...
@@ -4257,7 +4389,7 @@ select @b
var
retVal
=
p
.
Get
<
int
>(
"RetVal"
);
var
retVal
=
p
.
Get
<
int
>(
"RetVal"
);
retVal
.
IsEqualTo
(
3
);
retVal
.
IsEqualTo
(
3
);
}
}
#if EXTERNALS
class
SO29596645_RuleTableValuedParameters
:
Dapper
.
SqlMapper
.
IDynamicParameters
{
class
SO29596645_RuleTableValuedParameters
:
Dapper
.
SqlMapper
.
IDynamicParameters
{
private
string
parameterName
;
private
string
parameterName
;
...
@@ -4289,7 +4421,7 @@ public SO29596645_OrganisationDTO()
...
@@ -4289,7 +4421,7 @@ public SO29596645_OrganisationDTO()
Rules
=
new
SO29596645_RuleTableValuedParameters
(
"@Rules"
);
Rules
=
new
SO29596645_RuleTableValuedParameters
(
"@Rules"
);
}
}
}
}
#endif
#if POSTGRESQL
#if POSTGRESQL
class
Cat
class
Cat
...
...
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