FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Dapper/Dapper.EntityFramework/DbGeometryHandler.cs at main · DapperLib/Dapper · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
DapperLib
/
Dapper
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
3.7k
Star
18.4k
Code
Issues
463
Pull requests
83
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Dapper
/
Dapper.EntityFramework
/
DbGeometryHandler.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
59 lines (55 loc) · 2.01 KB
Breadcrumbs
Dapper
/
Dapper.EntityFramework
/
DbGeometryHandler.cs
Copy path
File metadata and controls
59 lines (55 loc) · 2.01 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using
Microsoft
.
SqlServer
.
Types
;
using
System
;
using
System
.
Data
;
using
System
.
Data
.
Entity
.
Spatial
;
using
System
.
Data
.
SqlClient
;
using
System
.
Data
.
SqlTypes
;
namespace
Dapper
.
EntityFramework
{
/// <summary>
/// Type-handler for the DbGeometry spatial type.
/// </summary>
public
class
DbGeometryHandler
:
SqlMapper
.
TypeHandler
<
DbGeometry
>
{
/// <summary>
/// Create a new handler instance.
/// </summary>
protected
DbGeometryHandler
(
)
{
/* create new */
}
/// <summary>
/// Default handler instance.
/// </summary>
public
static
readonly
DbGeometryHandler
Default
=
new
DbGeometryHandler
(
)
;
/// <summary>
/// Assign the value of a parameter before a command executes.
/// </summary>
/// <param name="parameter">The parameter to configure.</param>
/// <param name="value">Parameter value.</param>
public
override
void
SetValue
(
IDbDataParameter
parameter
,
DbGeometry
?
value
)
{
object
?
parsed
=
null
;
if
(
value
is
not
null
)
{
parsed
=
SqlGeometry
.
STGeomFromWKB
(
new
SqlBytes
(
value
.
AsBinary
(
)
)
,
value
.
CoordinateSystemId
)
;
}
parameter
.
Value
=
parsed
??
DBNull
.
Value
;
if
(
parameter
is
SqlParameter
sqlP
)
{
sqlP
.
UdtTypeName
=
"geometry"
;
}
}
/// <summary>
/// Parse a database value back to a typed value.
/// </summary>
/// <param name="value">The value from the database.</param>
/// <returns>The typed value.</returns>
public
override
DbGeometry
?
Parse
(
object
?
value
)
{
if
(
value
is
null
||
value
is
DBNull
)
return
null
;
if
(
value
is
SqlGeometry
geo
)
{
return
DbGeometry
.
FromBinary
(
geo
.
STAsBinary
(
)
.
Value
,
geo
.
STSrid
.
Value
)
;
}
return
DbGeometry
.
FromText
(
value
.
ToString
(
)
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL