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
02644d77
Commit
02644d77
authored
May 20, 2017
by
Bill.B.Jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issue #731: AddDynamicParameters repeated if paramtype is DbStiring should work.
parent
fb443385
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
ParameterTests.cs
Dapper.Tests/ParameterTests.cs
+12
-0
DbString.cs
Dapper/DbString.cs
+16
-3
No files found.
Dapper.Tests/ParameterTests.cs
View file @
02644d77
...
@@ -1020,6 +1020,18 @@ public void Test_AddDynamicParametersRepeatedShouldWork()
...
@@ -1020,6 +1020,18 @@ public void Test_AddDynamicParametersRepeatedShouldWork()
i
.
IsEqualTo
(
123
);
i
.
IsEqualTo
(
123
);
}
}
[
Fact
]
public
void
Test_AddDynamicParametersRepeatedIfParamTypeIsDbStiringShouldWork
()
{
var
foo
=
new
DbString
()
{
Value
=
"123"
};
var
args
=
new
DynamicParameters
();
args
.
AddDynamicParams
(
new
{
Foo
=
foo
});
args
.
AddDynamicParams
(
new
{
Foo
=
foo
});
int
i
=
connection
.
Query
<
int
>(
"select @Foo"
,
args
).
Single
();
i
.
IsEqualTo
(
123
);
}
[
Fact
]
[
Fact
]
public
void
AllowIDictionaryParameters
()
public
void
AllowIDictionaryParameters
()
{
{
...
...
Dapper/DbString.cs
View file @
02644d77
...
@@ -55,8 +55,18 @@ public void AddParameter(IDbCommand command, string name)
...
@@ -55,8 +55,18 @@ public void AddParameter(IDbCommand command, string name)
{
{
throw
new
InvalidOperationException
(
"If specifying IsFixedLength, a Length must also be specified"
);
throw
new
InvalidOperationException
(
"If specifying IsFixedLength, a Length must also be specified"
);
}
}
var
param
=
command
.
CreateParameter
();
bool
add
=
!
command
.
Parameters
.
Contains
(
name
);
param
.
ParameterName
=
name
;
IDbDataParameter
param
;
if
(
add
)
{
param
=
command
.
CreateParameter
();
param
.
ParameterName
=
name
;
}
else
{
param
=
(
IDbDataParameter
)
command
.
Parameters
[
name
];
}
#pragma warning disable 0618
#pragma warning disable 0618
param
.
Value
=
SqlMapper
.
SanitizeParameterValue
(
Value
);
param
.
Value
=
SqlMapper
.
SanitizeParameterValue
(
Value
);
#pragma warning restore 0618
#pragma warning restore 0618
...
@@ -69,7 +79,10 @@ public void AddParameter(IDbCommand command, string name)
...
@@ -69,7 +79,10 @@ public void AddParameter(IDbCommand command, string name)
param
.
Size
=
Length
;
param
.
Size
=
Length
;
}
}
param
.
DbType
=
IsAnsi
?
(
IsFixedLength
?
DbType
.
AnsiStringFixedLength
:
DbType
.
AnsiString
)
:
(
IsFixedLength
?
DbType
.
StringFixedLength
:
DbType
.
String
);
param
.
DbType
=
IsAnsi
?
(
IsFixedLength
?
DbType
.
AnsiStringFixedLength
:
DbType
.
AnsiString
)
:
(
IsFixedLength
?
DbType
.
StringFixedLength
:
DbType
.
String
);
command
.
Parameters
.
Add
(
param
);
if
(
add
)
{
command
.
Parameters
.
Add
(
param
);
}
}
}
}
}
}
}
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