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
92644721
Commit
92644721
authored
Dec 19, 2015
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Be more defensive when adding SqlDataRecord handler; fix #424
parent
a3ebdfdb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
8 deletions
+21
-8
SqlMapper.cs
Dapper/SqlMapper.cs
+21
-8
No files found.
Dapper/SqlMapper.cs
View file @
92644721
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
using
System.Linq
;
using
System.Linq
;
using
System.Reflection
;
using
System.Reflection
;
using
System.Reflection.Emit
;
using
System.Reflection.Emit
;
using
System.Runtime.CompilerServices
;
using
System.Text
;
using
System.Text
;
using
System.Text.RegularExpressions
;
using
System.Text.RegularExpressions
;
using
System.Threading
;
using
System.Threading
;
...
@@ -214,23 +215,35 @@ static SqlMapper()
...
@@ -214,23 +215,35 @@ static SqlMapper()
[
typeof
(
TimeSpan
?)]
=
DbType
.
Time
,
[
typeof
(
TimeSpan
?)]
=
DbType
.
Time
,
[
typeof
(
object
)]
=
DbType
.
Object
[
typeof
(
object
)]
=
DbType
.
Object
};
};
#if !COREFX
ResetTypeHandlers
(
false
);
AddTypeHandlerImpl
(
typeof
(
DataTable
),
new
DataTableHandler
(),
false
);
AddTypeHandlerImpl
(
typeof
(
IEnumerable
<
Microsoft
.
SqlServer
.
Server
.
SqlDataRecord
>),
new
SqlDataRecordHandler
(),
false
);
#endif
}
}
/// <summary>
/// <summary>
/// Clear the registered type handlers
/// Clear the registered type handlers
/// </summary>
/// </summary>
public
static
void
ResetTypeHandlers
()
public
static
void
ResetTypeHandlers
()
{
ResetTypeHandlers
(
true
);
}
private
static
void
ResetTypeHandlers
(
bool
clone
)
{
{
typeHandlers
=
new
Dictionary
<
Type
,
ITypeHandler
>();
typeHandlers
=
new
Dictionary
<
Type
,
ITypeHandler
>();
#if !COREFX
#if !COREFX
AddTypeHandlerImpl
(
typeof
(
DataTable
),
new
DataTableHandler
(),
true
);
AddTypeHandlerImpl
(
typeof
(
DataTable
),
new
DataTableHandler
(),
clone
);
AddTypeHandlerImpl
(
typeof
(
IEnumerable
<
Microsoft
.
SqlServer
.
Server
.
SqlDataRecord
>),
new
SqlDataRecordHandler
(),
true
);
try
// see https://github.com/StackExchange/dapper-dot-net/issues/424
{
AddSqlDataRecordsTypeHandler
(
clone
);
}
catch
{
}
#endif
#endif
}
}
#if !COREFX
[
MethodImpl
(
MethodImplOptions
.
NoInlining
)]
private
static
void
AddSqlDataRecordsTypeHandler
(
bool
clone
)
{
AddTypeHandlerImpl
(
typeof
(
IEnumerable
<
Microsoft
.
SqlServer
.
Server
.
SqlDataRecord
>),
new
SqlDataRecordHandler
(),
clone
);
}
#endif
/// <summary>
/// <summary>
/// Configure the specified type to be mapped to a given db-type
/// Configure the specified type to be mapped to a given db-type
/// </summary>
/// </summary>
...
@@ -310,8 +323,8 @@ public static void AddTypeHandler<T>(TypeHandler<T> handler)
...
@@ -310,8 +323,8 @@ public static void AddTypeHandler<T>(TypeHandler<T> handler)
{
{
AddTypeHandlerImpl
(
typeof
(
T
),
handler
,
true
);
AddTypeHandlerImpl
(
typeof
(
T
),
handler
,
true
);
}
}
private
static
Dictionary
<
Type
,
ITypeHandler
>
typeHandlers
=
new
Dictionary
<
Type
,
ITypeHandler
>()
;
private
static
Dictionary
<
Type
,
ITypeHandler
>
typeHandlers
;
internal
const
string
LinqBinary
=
"System.Data.Linq.Binary"
;
internal
const
string
LinqBinary
=
"System.Data.Linq.Binary"
;
...
...
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