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
2bef80f3
Commit
2bef80f3
authored
Apr 28, 2011
by
Sam Saffron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multimap was not buffered properly
parent
80c90d17
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
10 deletions
+19
-10
SqlMapper.cs
Dapper/SqlMapper.cs
+16
-9
Tests.cs
Tests/Tests.cs
+3
-1
No files found.
Dapper/SqlMapper.cs
View file @
2bef80f3
...
@@ -163,7 +163,7 @@ public static IEnumerable<dynamic> Query(this IDbConnection cnn, string sql, dyn
...
@@ -163,7 +163,7 @@ public static IEnumerable<dynamic> Query(this IDbConnection cnn, string sql, dyn
public
static
IEnumerable
<
T
>
Query
<
T
>(
this
IDbConnection
cnn
,
string
sql
,
dynamic
param
=
null
,
IDbTransaction
transaction
=
null
,
bool
buffered
=
true
,
int
?
commandTimeout
=
null
)
public
static
IEnumerable
<
T
>
Query
<
T
>(
this
IDbConnection
cnn
,
string
sql
,
dynamic
param
=
null
,
IDbTransaction
transaction
=
null
,
bool
buffered
=
true
,
int
?
commandTimeout
=
null
)
{
{
var
data
=
QueryInternal
<
T
>(
cnn
,
sql
,
param
as
object
,
transaction
,
commandTimeout
);
var
data
=
QueryInternal
<
T
>(
cnn
,
sql
,
param
as
object
,
transaction
,
commandTimeout
);
return
(
buffered
)
?
data
.
ToList
()
:
data
;
return
buffered
?
data
.
ToList
()
:
data
;
}
}
/// <summary>
/// <summary>
...
@@ -231,7 +231,13 @@ private static IEnumerable<T> QueryInternal<T>(this IDbConnection cnn, string sq
...
@@ -231,7 +231,13 @@ private static IEnumerable<T> QueryInternal<T>(this IDbConnection cnn, string sq
class
DontMap
{}
class
DontMap
{}
static
IEnumerable
<
T
>
MultiMap
<
T
,
U
,
V
,
Z
,
X
>(
this
IDbConnection
cnn
,
string
sql
,
object
map
,
object
param
=
null
,
IDbTransaction
transaction
=
null
,
bool
buffered
=
true
,
string
splitOn
=
"Id"
,
int
?
commandTimeout
=
null
)
static
IEnumerable
<
T
>
MultiMap
<
T
,
U
,
V
,
Z
,
X
>(
this
IDbConnection
cnn
,
string
sql
,
object
map
,
object
param
=
null
,
IDbTransaction
transaction
=
null
,
bool
buffered
=
true
,
string
splitOn
=
"Id"
,
int
?
commandTimeout
=
null
)
{
{
var
identity
=
new
Identity
(
sql
,
cnn
,
typeof
(
T
),
param
==
null
?
null
:
param
.
GetType
(),
otherTypes
:
new
[]
{
typeof
(
T
),
typeof
(
U
),
typeof
(
V
),
typeof
(
Z
),
typeof
(
X
)
});
var
results
=
MultiMapImpl
<
T
,
U
,
V
,
Z
,
X
>(
cnn
,
sql
,
map
,
param
,
transaction
,
splitOn
,
commandTimeout
);
return
buffered
?
results
.
ToList
()
:
results
;
}
static
IEnumerable
<
T
>
MultiMapImpl
<
T
,
U
,
V
,
Z
,
X
>(
this
IDbConnection
cnn
,
string
sql
,
object
map
,
object
param
=
null
,
IDbTransaction
transaction
=
null
,
string
splitOn
=
"Id"
,
int
?
commandTimeout
=
null
)
{
var
identity
=
new
Identity
(
sql
,
cnn
,
typeof
(
T
),
param
==
null
?
null
:
param
.
GetType
(),
otherTypes
:
new
[]
{
typeof
(
T
),
typeof
(
U
),
typeof
(
V
),
typeof
(
Z
),
typeof
(
X
)
});
var
info
=
GetCacheInfo
(
param
,
identity
);
var
info
=
GetCacheInfo
(
param
,
identity
);
using
(
var
cmd
=
SetupCommand
(
cnn
,
transaction
,
sql
,
info
.
ParamReader
,
param
,
commandTimeout
))
using
(
var
cmd
=
SetupCommand
(
cnn
,
transaction
,
sql
,
info
.
ParamReader
,
param
,
commandTimeout
))
...
@@ -249,7 +255,7 @@ class DontMap {}
...
@@ -249,7 +255,7 @@ class DontMap {}
for
(
pos
=
current
+
1
;
pos
<
reader
.
FieldCount
;
pos
++)
for
(
pos
=
current
+
1
;
pos
<
reader
.
FieldCount
;
pos
++)
{
{
// some people like ID some id ... assuming case insensitive splits for now
// some people like ID some id ... assuming case insensitive splits for now
if
(
string
.
Equals
(
reader
.
GetName
(
pos
),
splitOn
,
StringComparison
.
InvariantCultureIgnoreCase
))
if
(
string
.
Equals
(
reader
.
GetName
(
pos
),
splitOn
,
StringComparison
.
InvariantCultureIgnoreCase
))
{
{
break
;
break
;
}
}
...
@@ -259,10 +265,10 @@ class DontMap {}
...
@@ -259,10 +265,10 @@ class DontMap {}
};
};
var
otherDeserializer
=
new
List
<
object
>();
var
otherDeserializer
=
new
List
<
object
>();
split
=
nextSplit
();
split
=
nextSplit
();
info
.
Deserializer
=
GetDeserializer
<
T
>(
identity
,
reader
,
0
,
split
);
info
.
Deserializer
=
GetDeserializer
<
T
>(
identity
,
reader
,
0
,
split
);
if
(
typeof
(
U
)
!=
typeof
(
DontMap
))
if
(
typeof
(
U
)
!=
typeof
(
DontMap
))
{
{
var
next
=
nextSplit
();
var
next
=
nextSplit
();
...
@@ -296,7 +302,7 @@ class DontMap {}
...
@@ -296,7 +302,7 @@ class DontMap {}
var
deserializer2
=
(
Func
<
IDataReader
,
U
>)
info
.
OtherDeserializers
[
0
];
var
deserializer2
=
(
Func
<
IDataReader
,
U
>)
info
.
OtherDeserializers
[
0
];
Func
<
IDataReader
,
T
>
mapIt
=
null
;
Func
<
IDataReader
,
T
>
mapIt
=
null
;
if
(
info
.
OtherDeserializers
.
Length
==
1
)
if
(
info
.
OtherDeserializers
.
Length
==
1
)
{
{
...
@@ -347,15 +353,16 @@ class DontMap {}
...
@@ -347,15 +353,16 @@ class DontMap {}
}
}
}
}
if
(
mapIt
!=
null
)
if
(
mapIt
!=
null
)
while
(
reader
.
Read
())
while
(
reader
.
Read
())
{
{
yield
return
mapIt
(
reader
);
yield
return
mapIt
(
reader
);
}
}
}
}
}
}
}
}
private
static
CacheInfo
GetCacheInfo
(
object
param
,
Identity
identity
)
private
static
CacheInfo
GetCacheInfo
(
object
param
,
Identity
identity
)
{
{
CacheInfo
info
;
CacheInfo
info
;
...
...
Tests/Tests.cs
View file @
2bef80f3
...
@@ -432,7 +432,8 @@ public void MultiRSSqlCE()
...
@@ -432,7 +432,8 @@ public void MultiRSSqlCE()
cnn
.
Close
();
cnn
.
Close
();
}
}
}
}
/* TODO:
*
public void TestMagicParam()
public void TestMagicParam()
{
{
// magic params allow you to pass in single params without using an anon class
// magic params allow you to pass in single params without using an anon class
...
@@ -441,6 +442,7 @@ public void TestMagicParam()
...
@@ -441,6 +442,7 @@ public void TestMagicParam()
var first = connection.Query("select @a as a", 1).First();
var first = connection.Query("select @a as a", 1).First();
Assert.IsEqualTo(first.a, 1);
Assert.IsEqualTo(first.a, 1);
}
}
* */
}
}
}
}
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