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
38b3f224
Commit
38b3f224
authored
Dec 19, 2011
by
Sam Saffron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow for lists of DbString in a 'IN' clause
parent
d9306233
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
SqlMapper.cs
Dapper/SqlMapper.cs
+10
-2
Tests.cs
Tests/Tests.cs
+9
-0
No files found.
Dapper/SqlMapper.cs
View file @
38b3f224
...
@@ -1147,6 +1147,7 @@ public static void PackListParameters(IDbCommand command, string namePrefix, obj
...
@@ -1147,6 +1147,7 @@ public static void PackListParameters(IDbCommand command, string namePrefix, obj
if
(
list
!=
null
)
if
(
list
!=
null
)
{
{
bool
isString
=
value
is
IEnumerable
<
string
>;
bool
isString
=
value
is
IEnumerable
<
string
>;
bool
isDbString
=
value
is
IEnumerable
<
DbString
>;
foreach
(
var
item
in
list
)
foreach
(
var
item
in
list
)
{
{
count
++;
count
++;
...
@@ -1161,7 +1162,15 @@ public static void PackListParameters(IDbCommand command, string namePrefix, obj
...
@@ -1161,7 +1162,15 @@ public static void PackListParameters(IDbCommand command, string namePrefix, obj
listParam
.
Size
=
-
1
;
listParam
.
Size
=
-
1
;
}
}
}
}
command
.
Parameters
.
Add
(
listParam
);
if
(
isDbString
&&
item
as
DbString
!=
null
)
{
var
str
=
item
as
DbString
;
str
.
AddParameter
(
command
,
listParam
.
ParameterName
);
}
else
{
command
.
Parameters
.
Add
(
listParam
);
}
}
}
if
(
count
==
0
)
if
(
count
==
0
)
...
@@ -1197,7 +1206,6 @@ private static IEnumerable<PropertyInfo> FilterParameters(IEnumerable<PropertyIn
...
@@ -1197,7 +1206,6 @@ private static IEnumerable<PropertyInfo> FilterParameters(IEnumerable<PropertyIn
{
{
Type
type
=
identity
.
parametersType
;
Type
type
=
identity
.
parametersType
;
bool
filterParams
=
identity
.
commandType
.
GetValueOrDefault
(
CommandType
.
Text
)
==
CommandType
.
Text
;
bool
filterParams
=
identity
.
commandType
.
GetValueOrDefault
(
CommandType
.
Text
)
==
CommandType
.
Text
;
var
dm
=
new
DynamicMethod
(
string
.
Format
(
"ParamInfo{0}"
,
Guid
.
NewGuid
()),
null
,
new
[]
{
typeof
(
IDbCommand
),
typeof
(
object
)
},
type
,
true
);
var
dm
=
new
DynamicMethod
(
string
.
Format
(
"ParamInfo{0}"
,
Guid
.
NewGuid
()),
null
,
new
[]
{
typeof
(
IDbCommand
),
typeof
(
object
)
},
type
,
true
);
var
il
=
dm
.
GetILGenerator
();
var
il
=
dm
.
GetILGenerator
();
...
...
Tests/Tests.cs
View file @
38b3f224
...
@@ -17,6 +17,15 @@ class Tests
...
@@ -17,6 +17,15 @@ class Tests
SqlConnection
connection
=
Program
.
GetOpenConnection
();
SqlConnection
connection
=
Program
.
GetOpenConnection
();
public
void
TestListOfAnsiStrings
()
{
var
results
=
connection
.
Query
<
string
>(
"select * from (select 'a' str union select 'b' union select 'c') X where str in @strings"
,
new
{
strings
=
new
[]
{
new
DbString
{
IsAnsi
=
true
,
Value
=
"a"
},
new
DbString
{
IsAnsi
=
true
,
Value
=
"b"
}
}
}).
ToList
();
results
[
0
].
IsEqualTo
(
"a"
);
results
[
1
].
IsEqualTo
(
"b"
);
}
public
void
TestNullableGuidSupport
()
public
void
TestNullableGuidSupport
()
{
{
var
guid
=
connection
.
Query
<
Guid
?>(
"select null"
).
First
();
var
guid
=
connection
.
Query
<
Guid
?>(
"select null"
).
First
();
...
...
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