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
10c51f42
Commit
10c51f42
authored
May 14, 2014
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
async multiplexed / pipeline implemented 1.24
parent
1393169c
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
111 additions
and
29 deletions
+111
-29
AssemblyInfo.cs
Dapper NET40/Properties/AssemblyInfo.cs
+2
-2
SqlMapperAsync.cs
Dapper NET45/SqlMapperAsync.cs
+41
-9
AssemblyInfo.cs
Dapper.Contrib.Tests/Properties/AssemblyInfo.cs
+2
-2
AssemblyInfo.cs
Dapper.Contrib/Properties/AssemblyInfo.cs
+2
-2
AssemblyInfo.cs
Dapper.SqlBuilder/Properties/AssemblyInfo.cs
+2
-2
AssemblyInfo.cs
DapperTests NET35/Properties/AssemblyInfo.cs
+2
-2
Program.cs
DapperTests NET45/Program.cs
+9
-2
AssemblyInfo.cs
DapperTests NET45/Properties/AssemblyInfo.cs
+2
-2
Tests.cs
DapperTests NET45/Tests.cs
+21
-0
AssemblyInfo.cs
Tests/Properties/AssemblyInfo.cs
+2
-2
Tests.cs
Tests/Tests.cs
+24
-3
dapper.nuspec
dapper.nuspec
+2
-1
No files found.
Dapper NET40/Properties/AssemblyInfo.cs
View file @
10c51f42
...
@@ -32,5 +32,5 @@
...
@@ -32,5 +32,5 @@
//
//
// You can specify all the values or you can default the Build and Revision Numbers
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.2
4
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
4
.0.0"
)]
Dapper NET45/SqlMapperAsync.cs
View file @
10c51f42
...
@@ -71,6 +71,7 @@ public static Task<int> ExecuteAsync(this IDbConnection cnn, CommandDefinition c
...
@@ -71,6 +71,7 @@ public static Task<int> ExecuteAsync(this IDbConnection cnn, CommandDefinition c
return
ExecuteImplAsync
(
cnn
,
command
,
param
);
return
ExecuteImplAsync
(
cnn
,
command
,
param
);
}
}
}
}
private
static
async
Task
<
int
>
ExecuteMultiImplAsync
(
IDbConnection
cnn
,
CommandDefinition
command
,
IEnumerable
multiExec
)
private
static
async
Task
<
int
>
ExecuteMultiImplAsync
(
IDbConnection
cnn
,
CommandDefinition
command
,
IEnumerable
multiExec
)
{
{
bool
isFirst
=
true
;
bool
isFirst
=
true
;
...
@@ -79,10 +80,40 @@ private static async Task<int> ExecuteMultiImplAsync(IDbConnection cnn, CommandD
...
@@ -79,10 +80,40 @@ private static async Task<int> ExecuteMultiImplAsync(IDbConnection cnn, CommandD
try
try
{
{
if
(
wasClosed
)
await
((
DbConnection
)
cnn
).
OpenAsync
().
ConfigureAwait
(
false
);
if
(
wasClosed
)
await
((
DbConnection
)
cnn
).
OpenAsync
().
ConfigureAwait
(
false
);
CacheInfo
info
=
null
;
if
((
command
.
Flags
&
CommandFlags
.
Pipelined
)
!=
0
)
{
const
int
MAX_PENDING
=
100
;
var
pending
=
new
Queue
<
Task
<
int
>>(
MAX_PENDING
);
foreach
(
var
obj
in
multiExec
)
{
var
cmd
=
(
DbCommand
)
command
.
SetupCommand
(
cnn
,
null
);
if
(
isFirst
)
{
isFirst
=
false
;
var
identity
=
new
Identity
(
command
.
CommandText
,
cmd
.
CommandType
,
cnn
,
null
,
obj
.
GetType
(),
null
);
info
=
GetCacheInfo
(
identity
,
obj
);
}
info
.
ParamReader
(
cmd
,
obj
);
var
task
=
cmd
.
ExecuteNonQueryAsync
(
command
.
CancellationToken
);
pending
.
Enqueue
(
task
);
if
(
pending
.
Count
==
MAX_PENDING
)
{
total
+=
await
pending
.
Dequeue
().
ConfigureAwait
(
false
);
}
}
while
(
pending
.
Count
!=
0
)
{
total
+=
await
pending
.
Dequeue
().
ConfigureAwait
(
false
);
}
return
total
;
}
else
{
using
(
var
cmd
=
(
DbCommand
)
command
.
SetupCommand
(
cnn
,
null
))
using
(
var
cmd
=
(
DbCommand
)
command
.
SetupCommand
(
cnn
,
null
))
{
{
string
masterSql
=
null
;
string
masterSql
=
null
;
CacheInfo
info
=
null
;
foreach
(
var
obj
in
multiExec
)
foreach
(
var
obj
in
multiExec
)
{
{
if
(
isFirst
)
if
(
isFirst
)
...
@@ -98,7 +129,8 @@ private static async Task<int> ExecuteMultiImplAsync(IDbConnection cnn, CommandD
...
@@ -98,7 +129,8 @@ private static async Task<int> ExecuteMultiImplAsync(IDbConnection cnn, CommandD
cmd
.
Parameters
.
Clear
();
// current code is Add-tastic
cmd
.
Parameters
.
Clear
();
// current code is Add-tastic
}
}
info
.
ParamReader
(
cmd
,
obj
);
info
.
ParamReader
(
cmd
,
obj
);
total
+=
await
cmd
.
ExecuteNonQueryAsync
().
ConfigureAwait
(
false
);
total
+=
await
cmd
.
ExecuteNonQueryAsync
(
command
.
CancellationToken
).
ConfigureAwait
(
false
);
}
}
}
}
}
}
}
...
...
Dapper.Contrib.Tests/Properties/AssemblyInfo.cs
View file @
10c51f42
...
@@ -31,5 +31,5 @@
...
@@ -31,5 +31,5 @@
//
//
// You can specify all the values or you can default the Build and Revision Numbers
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.2
4
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
4
.0.0"
)]
Dapper.Contrib/Properties/AssemblyInfo.cs
View file @
10c51f42
...
@@ -31,5 +31,5 @@
...
@@ -31,5 +31,5 @@
//
//
// You can specify all the values or you can default the Build and Revision Numbers
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.2
4
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
4
.0.0"
)]
Dapper.SqlBuilder/Properties/AssemblyInfo.cs
View file @
10c51f42
...
@@ -31,5 +31,5 @@
...
@@ -31,5 +31,5 @@
//
//
// You can specify all the values or you can default the Build and Revision Numbers
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.2
4
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
4
.0.0"
)]
DapperTests NET35/Properties/AssemblyInfo.cs
View file @
10c51f42
...
@@ -31,5 +31,5 @@
...
@@ -31,5 +31,5 @@
//
//
// You can specify all the values or you can default the Build and Revision Numbers
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.2
4
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
4
.0.0"
)]
DapperTests NET45/Program.cs
View file @
10c51f42
...
@@ -16,9 +16,16 @@ static void Main()
...
@@ -16,9 +16,16 @@ static void Main()
}
}
public
static
readonly
string
connectionString
=
"Data Source=.;Initial Catalog=tempdb;Integrated Security=True"
;
public
static
readonly
string
connectionString
=
"Data Source=.;Initial Catalog=tempdb;Integrated Security=True"
;
public
static
SqlConnection
GetOpenConnection
()
public
static
SqlConnection
GetOpenConnection
(
bool
mars
=
false
)
{
{
var
connection
=
new
SqlConnection
(
connectionString
);
var
cs
=
connectionString
;
if
(
mars
)
{
SqlConnectionStringBuilder
scsb
=
new
SqlConnectionStringBuilder
(
cs
);
scsb
.
MultipleActiveResultSets
=
true
;
cs
=
scsb
.
ConnectionString
;
}
var
connection
=
new
SqlConnection
(
cs
);
connection
.
Open
();
connection
.
Open
();
return
connection
;
return
connection
;
}
}
...
...
DapperTests NET45/Properties/AssemblyInfo.cs
View file @
10c51f42
...
@@ -31,5 +31,5 @@
...
@@ -31,5 +31,5 @@
//
//
// You can specify all the values or you can default the Build and Revision Numbers
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.2
4
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
4
.0.0"
)]
DapperTests NET45/Tests.cs
View file @
10c51f42
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
using
Dapper
;
using
Dapper
;
using
SqlMapper
;
using
SqlMapper
;
using
System.Data
;
using
System.Data
;
using
System.Diagnostics
;
namespace
DapperTests_NET45
namespace
DapperTests_NET45
{
{
...
@@ -207,6 +208,26 @@ public void LiteralIn()
...
@@ -207,6 +208,26 @@ public void LiteralIn()
}
}
}
}
public
void
RunSequentialVersusParallel
()
{
var
ids
=
Enumerable
.
Range
(
1
,
2000
).
Select
(
id
=>
new
{
id
}).
ToArray
();
using
(
var
connection
=
Program
.
GetOpenConnection
(
true
))
{
connection
.
ExecuteAsync
(
new
CommandDefinition
(
"select @id"
,
ids
.
Take
(
5
),
flags
:
CommandFlags
.
None
)).
Wait
();
var
watch
=
Stopwatch
.
StartNew
();
connection
.
ExecuteAsync
(
new
CommandDefinition
(
"select @id"
,
ids
,
flags
:
CommandFlags
.
None
)).
Wait
();
watch
.
Stop
();
System
.
Console
.
WriteLine
(
"No pipeline: {0}ms"
,
watch
.
ElapsedMilliseconds
);
watch
=
Stopwatch
.
StartNew
();
connection
.
ExecuteAsync
(
new
CommandDefinition
(
"select @id"
,
ids
,
flags
:
CommandFlags
.
Pipelined
)).
Wait
();
watch
.
Stop
();
System
.
Console
.
WriteLine
(
"Pipeline: {0}ms"
,
watch
.
ElapsedMilliseconds
);
}
}
class
Product
class
Product
{
{
public
int
Id
{
get
;
set
;
}
public
int
Id
{
get
;
set
;
}
...
...
Tests/Properties/AssemblyInfo.cs
View file @
10c51f42
...
@@ -31,5 +31,5 @@
...
@@ -31,5 +31,5 @@
//
//
// You can specify all the values or you can default the Build and Revision Numbers
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.2
4
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
4
.0.0"
)]
Tests/Tests.cs
View file @
10c51f42
...
@@ -2697,25 +2697,46 @@ enum AnEnum
...
@@ -2697,25 +2697,46 @@ enum AnEnum
A
=
2
,
A
=
2
,
B
=
1
B
=
1
}
}
enum
AnotherEnum
:
byte
{
A
=
2
,
B
=
1
}
public
void
LiteralReplacementEnumAndString
()
public
void
LiteralReplacementEnumAndString
()
{
{
var
args
=
new
{
x
=
AnEnum
.
B
,
y
=
123.45
M
};
var
args
=
new
{
x
=
AnEnum
.
B
,
y
=
123.45
M
,
z
=
AnotherEnum
.
A
};
var
row
=
connection
.
Query
(
"select {=x} as x,{=y} as y"
,
args
).
Single
();
var
row
=
connection
.
Query
(
"select {=x} as x,{=y} as y
,cast({=z} as tinyint) as z
"
,
args
).
Single
();
AnEnum
x
=
(
AnEnum
)(
int
)
row
.
x
;
AnEnum
x
=
(
AnEnum
)(
int
)
row
.
x
;
decimal
y
=
row
.
y
;
decimal
y
=
row
.
y
;
AnotherEnum
z
=
(
AnotherEnum
)(
byte
)
row
.
z
;
x
.
Equals
(
AnEnum
.
B
);
x
.
Equals
(
AnEnum
.
B
);
y
.
Equals
(
123.45
M
);
y
.
Equals
(
123.45
M
);
z
.
Equals
(
AnotherEnum
.
A
);
}
}
public
void
LiteralReplacementDynamicEnumAndString
()
public
void
LiteralReplacementDynamicEnumAndString
()
{
{
var
args
=
new
DynamicParameters
();
var
args
=
new
DynamicParameters
();
args
.
Add
(
"x"
,
AnEnum
.
B
);
args
.
Add
(
"x"
,
AnEnum
.
B
);
args
.
Add
(
"y"
,
123.45
M
);
args
.
Add
(
"y"
,
123.45
M
);
var
row
=
connection
.
Query
(
"select {=x} as x,{=y} as y"
,
args
).
Single
();
args
.
Add
(
"z"
,
AnotherEnum
.
A
);
var
row
=
connection
.
Query
(
"select {=x} as x,{=y} as y,cast({=z} as tinyint) as z"
,
args
).
Single
();
AnEnum
x
=
(
AnEnum
)(
int
)
row
.
x
;
AnEnum
x
=
(
AnEnum
)(
int
)
row
.
x
;
decimal
y
=
row
.
y
;
decimal
y
=
row
.
y
;
AnotherEnum
z
=
(
AnotherEnum
)(
byte
)
row
.
z
;
x
.
Equals
(
AnEnum
.
B
);
x
.
Equals
(
AnEnum
.
B
);
y
.
Equals
(
123.45
M
);
y
.
Equals
(
123.45
M
);
z
.
Equals
(
AnotherEnum
.
A
);
}
public
void
LiteralReplacementWithIn
()
{
var
data
=
connection
.
Query
<
MyRow
>(
"select @x where 1 in @ids and 1 ={=a}"
,
new
{
x
=
1
,
ids
=
new
[]
{
1
,
2
,
3
},
a
=
1
}).
ToList
();
}
class
MyRow
{
public
int
x
{
get
;
set
;
}
}
}
public
void
LiteralIn
()
public
void
LiteralIn
()
...
...
dapper.nuspec
View file @
10c51f42
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<package
xmlns=
"http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"
>
<package
xmlns=
"http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"
>
<metadata
schemaVersion=
"2"
>
<metadata
schemaVersion=
"2"
>
<id>
Dapper
</id>
<id>
Dapper
</id>
<version>
1.2
3
</version>
<version>
1.2
4
</version>
<title>
Dapper dot net
</title>
<title>
Dapper dot net
</title>
<authors>
Sam Saffron,Marc Gravell
</authors>
<authors>
Sam Saffron,Marc Gravell
</authors>
<owners>
Sam Saffron,Marc Gravell
</owners>
<owners>
Sam Saffron,Marc Gravell
</owners>
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
<frameworkAssembly
assemblyName=
"Microsoft.CSharp"
targetFramework=
".NETFramework4.0-Client, .NETFramework4.0"
/>
<frameworkAssembly
assemblyName=
"Microsoft.CSharp"
targetFramework=
".NETFramework4.0-Client, .NETFramework4.0"
/>
</frameworkAssemblies>
</frameworkAssemblies>
<releaseNotes>
<releaseNotes>
* 1.24 - Implement pipelined async multi-exec, when flag is specified (only - requires MARS etc)
* 1.23 - Improved support for optimize hints (@foo unknown) with list expansions
* 1.23 - Improved support for optimize hints (@foo unknown) with list expansions
* 1.22 - Literal support now extends to enumerable types (for "in" etc usage); move to command-flags model for "buffered" etc
* 1.22 - Literal support now extends to enumerable types (for "in" etc usage); move to command-flags model for "buffered" etc
* 1.21 - Limit literals to numeric types; for enums, use value not name
* 1.21 - Limit literals to numeric types; for enums, use value not name
...
...
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