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
f9bd30fb
Commit
f9bd30fb
authored
Jul 08, 2016
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify the string_split implementation
parent
c6d4379b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
SqlMapper.cs
Dapper/SqlMapper.cs
+6
-6
No files found.
Dapper/SqlMapper.cs
View file @
f9bd30fb
...
...
@@ -1990,13 +1990,13 @@ public static void PackListParameters(IDbCommand command, string namePrefix, obj
private
static
bool
TryStringSplit
(
ref
IEnumerable
list
,
int
splitAt
,
string
namePrefix
,
IDbCommand
command
)
{
if
(
list
==
null
||
splitAt
<
0
)
return
false
;
if
(
list
is
IEnumerable
<
int
>)
return
TryStringSplit
<
int
>(
ref
list
,
splitAt
,
namePrefix
,
command
,
"int
not null
"
,
if
(
list
is
IEnumerable
<
int
>)
return
TryStringSplit
<
int
>(
ref
list
,
splitAt
,
namePrefix
,
command
,
"int"
,
(
sb
,
i
)
=>
sb
.
Append
(
i
.
ToString
(
CultureInfo
.
InvariantCulture
)));
if
(
list
is
IEnumerable
<
long
>)
return
TryStringSplit
<
long
>(
ref
list
,
splitAt
,
namePrefix
,
command
,
"bigint
not null
"
,
if
(
list
is
IEnumerable
<
long
>)
return
TryStringSplit
<
long
>(
ref
list
,
splitAt
,
namePrefix
,
command
,
"bigint"
,
(
sb
,
i
)
=>
sb
.
Append
(
i
.
ToString
(
CultureInfo
.
InvariantCulture
)));
if
(
list
is
IEnumerable
<
short
>)
return
TryStringSplit
<
short
>(
ref
list
,
splitAt
,
namePrefix
,
command
,
"smallint
not null
"
,
if
(
list
is
IEnumerable
<
short
>)
return
TryStringSplit
<
short
>(
ref
list
,
splitAt
,
namePrefix
,
command
,
"smallint"
,
(
sb
,
i
)
=>
sb
.
Append
(
i
.
ToString
(
CultureInfo
.
InvariantCulture
)));
if
(
list
is
IEnumerable
<
byte
>)
return
TryStringSplit
<
byte
>(
ref
list
,
splitAt
,
namePrefix
,
command
,
"tinyint
not null
"
,
if
(
list
is
IEnumerable
<
byte
>)
return
TryStringSplit
<
byte
>(
ref
list
,
splitAt
,
namePrefix
,
command
,
"tinyint"
,
(
sb
,
i
)
=>
sb
.
Append
(
i
.
ToString
(
CultureInfo
.
InvariantCulture
)));
return
false
;
}
...
...
@@ -2024,12 +2024,12 @@ private static bool TryStringSplit(ref IEnumerable list, int splitAt, string nam
else
{
varName
=
variableName
;
return
"(select
val from "
+
variableName
+
"_TSS
)"
;
return
"(select
cast([value] as "
+
colType
+
") from string_split("
+
variableName
+
",',')
)"
;
}
},
RegexOptions
.
IgnoreCase
|
RegexOptions
.
Multiline
|
RegexOptions
.
CultureInvariant
);
if
(
varName
==
null
)
return
false
;
// couldn't resolve the var!
command
.
CommandText
=
"declare "
+
varName
+
"_TSS table(val "
+
colType
+
");insert "
+
varName
+
"_TSS (val) select value from string_split("
+
varName
+
",',');"
+
sql
;
command
.
CommandText
=
sql
;
var
concatenatedParam
=
command
.
CreateParameter
();
concatenatedParam
.
ParameterName
=
namePrefix
;
concatenatedParam
.
DbType
=
DbType
.
AnsiString
;
...
...
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