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
12d7617f
Commit
12d7617f
authored
May 16, 2014
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix and tests for
http://stackoverflow.com/q/23696254/23354
parent
9e5d28e4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
23 deletions
+43
-23
SqlMapper.cs
Dapper NET40/SqlMapper.cs
+6
-1
Tests.cs
Tests/Tests.cs
+37
-22
No files found.
Dapper NET40/SqlMapper.cs
View file @
12d7617f
...
...
@@ -1152,7 +1152,12 @@ private static IEnumerable<T> QueryImpl<T>(this IDbConnection cnn, CommandDefini
while
(
reader
.
Read
())
{
yield
return
(
T
)
func
(
reader
);
object
val
=
func
(
reader
);
if
(
val
==
null
||
val
is
T
)
{
yield
return
(
T
)
val
;
}
else
{
yield
return
(
T
)
Convert
.
ChangeType
(
val
,
typeof
(
T
));
}
}
// happy path; close the reader cleanly - no
// need for "Cancel" etc
...
...
Tests/Tests.cs
View file @
12d7617f
...
...
@@ -2671,7 +2671,7 @@ public void TestParameterInclusionNotSensitiveToCurrentCulture()
public
void
LiteralReplacement
()
{
connection
.
Execute
(
"create table #literal1 (id int not null, foo int not null)"
);
connection
.
Execute
(
"insert #literal1 (id,foo) values ({=id}, @foo)"
,
new
{
id
=
123
,
foo
=
456
});
connection
.
Execute
(
"insert #literal1 (id,foo) values ({=id}, @foo)"
,
new
{
id
=
123
,
foo
=
456
});
var
rows
=
new
[]
{
new
{
id
=
1
,
foo
=
2
},
new
{
id
=
3
,
foo
=
4
}
};
connection
.
Execute
(
"insert #literal1 (id,foo) values ({=id}, @foo)"
,
rows
);
var
count
=
connection
.
Query
<
int
>(
"select count(1) from #literal1 where id={=foo}"
,
new
{
foo
=
123
}).
Single
();
...
...
@@ -2799,6 +2799,21 @@ public void DbString()
b
.
IsEqualTo
(
6
);
}
class
HasInt32
{
public
int
Value
{
get
;
set
;
}
}
// http://stackoverflow.com/q/23696254/23354
public
void
DownwardIntegerConversion
()
{
const
string
sql
=
"select cast(42 as bigint) as Value"
;
int
i
=
connection
.
Query
<
HasInt32
>(
sql
).
Single
().
Value
;
Assert
.
IsEqualTo
(
42
,
i
);
i
=
connection
.
Query
<
int
>(
sql
).
Single
();
Assert
.
IsEqualTo
(
42
,
i
);
}
class
HasDoubleDecimal
{
public
double
A
{
get
;
set
;
}
...
...
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