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
c3e7dbc9
Commit
c3e7dbc9
authored
Jul 19, 2011
by
Sam Saffron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed #47 Get now supports DBNull properly
parent
9ec29b77
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
SqlMapper.cs
Dapper/SqlMapper.cs
+10
-1
Tests.cs
Tests/Tests.cs
+10
-0
No files found.
Dapper/SqlMapper.cs
View file @
c3e7dbc9
...
@@ -1586,7 +1586,16 @@ void SqlMapper.IDynamicParameters.AddParameters(IDbCommand command)
...
@@ -1586,7 +1586,16 @@ void SqlMapper.IDynamicParameters.AddParameters(IDbCommand command)
public
T
Get
<
T
>(
string
name
)
public
T
Get
<
T
>(
string
name
)
{
{
return
(
T
)
parameters
[
Clean
(
name
)].
AttachedParam
.
Value
;
var
val
=
parameters
[
Clean
(
name
)].
AttachedParam
.
Value
;
if
(
val
==
DBNull
.
Value
)
{
if
(
default
(
T
)
!=
null
)
{
throw
new
ApplicationException
(
"Attempting to cast a DBNull to a non nullable type!"
);
}
return
default
(
T
);
}
return
(
T
)
val
;
}
}
}
}
public
sealed
class
DbString
public
sealed
class
DbString
...
...
Tests/Tests.cs
View file @
c3e7dbc9
...
@@ -1026,5 +1026,15 @@ public void TestMultiMapThreeTypesWithGridReader()
...
@@ -1026,5 +1026,15 @@ public void TestMultiMapThreeTypesWithGridReader()
connection
.
Execute
(
"drop table #Users drop table #Posts drop table #Comments"
);
connection
.
Execute
(
"drop table #Users drop table #Posts drop table #Comments"
);
}
}
public
void
TestDynamicParamNullSupport
()
{
var
p
=
new
DynamicParameters
();
p
.
Add
(
"@b"
,
dbType
:
DbType
.
Int32
,
direction
:
ParameterDirection
.
Output
);
connection
.
Execute
(
"select @b = null"
,
p
);
p
.
Get
<
int
?>(
"@b"
).
IsNull
();
}
}
}
}
}
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