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
54bc52b3
Commit
54bc52b3
authored
Aug 28, 2014
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.32: Support for SqlGeography in core library
parent
6600c66b
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
64 additions
and
73 deletions
+64
-73
AssemblyInfo.cs
Dapper NET40/Properties/AssemblyInfo.cs
+2
-2
SqlMapper.cs
Dapper NET40/SqlMapper.cs
+37
-2
AssemblyInfo.cs
Dapper.Contrib.Tests/Properties/AssemblyInfo.cs
+2
-2
AssemblyInfo.cs
Dapper.Contrib/Properties/AssemblyInfo.cs
+2
-2
Dapper.EntityFramework NET40.csproj
...EntityFramework NET40/Dapper.EntityFramework NET40.csproj
+0
-3
Dapper.EntityFramework NET45.csproj
...EntityFramework NET45/Dapper.EntityFramework NET45.csproj
+0
-1
Handlers.cs
Dapper.EntityFramework NET45/Handlers.cs
+1
-4
SqlGeographyHandler.cs
Dapper.EntityFramework NET45/SqlGeographyHandler.cs
+0
-45
AssemblyInfo.cs
Dapper.SqlBuilder/Properties/AssemblyInfo.cs
+2
-2
AssemblyInfo.cs
DapperTests NET35/Properties/AssemblyInfo.cs
+2
-2
AssemblyInfo.cs
DapperTests NET45/Properties/AssemblyInfo.cs
+2
-2
AssemblyInfo.cs
Tests/Properties/AssemblyInfo.cs
+2
-2
Tests.cs
Tests/Tests.cs
+2
-3
app.config
Tests/app.config
+8
-0
dapper.nuspec
dapper.nuspec
+2
-1
No files found.
Dapper NET40/Properties/AssemblyInfo.cs
View file @
54bc52b3
...
...
@@ -32,5 +32,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.3
1
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.3
1
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.3
2
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.3
2
.0.0"
)]
Dapper NET40/SqlMapper.cs
View file @
54bc52b3
...
...
@@ -276,6 +276,36 @@ public interface ITypeHandler
object
Parse
(
Type
destinationType
,
object
value
);
}
/// <summary>
/// A type handler for data-types that are supported by the underlying provider, but which need
/// a well-known UdtTypeName to be specified
/// </summary>
public
class
UdtTypeHandler
:
ITypeHandler
{
private
readonly
string
udtTypeName
;
/// <summary>
/// Creates a new instance of UdtTypeHandler with the specified UdtTypeName
/// </summary>
public
UdtTypeHandler
(
string
udtTypeName
)
{
if
(
string
.
IsNullOrEmpty
(
udtTypeName
))
throw
new
ArgumentException
(
"Cannot be null or empty"
,
udtTypeName
);
this
.
udtTypeName
=
udtTypeName
;
}
object
ITypeHandler
.
Parse
(
Type
destinationType
,
object
value
)
{
return
value
is
DBNull
?
null
:
value
;
}
void
ITypeHandler
.
SetValue
(
IDbDataParameter
parameter
,
object
value
)
{
parameter
.
Value
=
((
object
)
value
)
??
DBNull
.
Value
;
if
(
parameter
is
System
.
Data
.
SqlClient
.
SqlParameter
)
{
((
System
.
Data
.
SqlClient
.
SqlParameter
)
parameter
).
UdtTypeName
=
udtTypeName
;
}
}
}
/// <summary>
/// Base-class for simple type-handlers
/// </summary>
...
...
@@ -809,10 +839,15 @@ internal static DbType LookupDbType(Type type, string name, out ITypeHandler han
{
return
DbType
.
Object
;
}
throw
new
NotSupportedException
(
string
.
Format
(
"The member {0} of type {1} cannot be used as a parameter value"
,
name
,
type
));
if
(
type
.
FullName
==
"Microsoft.SqlServer.Types.SqlGeography"
)
{
handler
=
new
UdtTypeHandler
(
"GEOGRAPHY"
);
AddTypeHandler
(
type
,
handler
);
return
DbType
.
Object
;
}
throw
new
NotSupportedException
(
string
.
Format
(
"The member {0} of type {1} cannot be used as a parameter value"
,
name
,
type
));
}
/// <summary>
/// Identity of a cached query in Dapper, used for extensability
/// </summary>
...
...
Dapper.Contrib.Tests/Properties/AssemblyInfo.cs
View file @
54bc52b3
...
...
@@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.3
1
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.3
1
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.3
2
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.3
2
.0.0"
)]
Dapper.Contrib/Properties/AssemblyInfo.cs
View file @
54bc52b3
...
...
@@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.3
1
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.3
1
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.3
2
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.3
2
.0.0"
)]
Dapper.EntityFramework NET40/Dapper.EntityFramework NET40.csproj
View file @
54bc52b3
...
...
@@ -60,9 +60,6 @@
<Compile
Include=
"..\Dapper.EntityFramework NET45\Handlers.cs"
>
<Link>
Handlers.cs
</Link>
</Compile>
<Compile
Include=
"..\Dapper.EntityFramework NET45\SqlGeographyHandler.cs"
>
<Link>
SqlGeographyHandler.cs
</Link>
</Compile>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"SqlServerTypes\Loader.cs"
/>
</ItemGroup>
...
...
Dapper.EntityFramework NET45/Dapper.EntityFramework NET45.csproj
View file @
54bc52b3
...
...
@@ -55,7 +55,6 @@
<Compile
Include=
"DbGeographyHandler.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Handlers.cs"
/>
<Compile
Include=
"SqlGeographyHandler.cs"
/>
<Compile
Include=
"SqlServerTypes\Loader.cs"
/>
</ItemGroup>
<ItemGroup>
...
...
Dapper.EntityFramework NET45/Handlers.cs
View file @
54bc52b3
using
Microsoft.SqlServer.Types
;
namespace
Dapper.EntityFramework
namespace
Dapper.EntityFramework
{
/// <summary>
/// Acts on behalf of all type-handlers in this package
...
...
@@ -13,7 +11,6 @@ public static class Handlers
public
static
void
Register
()
{
SqlMapper
.
AddTypeHandler
(
DbGeographyHandler
.
Default
);
SqlMapper
.
AddTypeHandler
(
SqlGeographyHandler
.
Default
);
}
}
}
Dapper.EntityFramework NET45/SqlGeographyHandler.cs
deleted
100644 → 0
View file @
6600c66b
using
Microsoft.SqlServer.Types
;
using
System
;
using
System.Data
;
using
System.Data.Entity.Spatial
;
using
System.Data.SqlClient
;
namespace
Dapper.EntityFramework
{
/// <summary>
/// Type-handler for the DbGeography spatial type
/// </summary>
public
class
SqlGeographyHandler
:
Dapper
.
SqlMapper
.
TypeHandler
<
SqlGeography
>
{
/// <summary>
/// Create a new handler instance
/// </summary>
protected
SqlGeographyHandler
()
{
}
/// <summary>
/// Default handler instance
/// </summary>
public
static
readonly
SqlGeographyHandler
Default
=
new
SqlGeographyHandler
();
/// <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
,
SqlGeography
value
)
{
parameter
.
Value
=
((
object
)
value
)
??
DBNull
.
Value
;
if
(
parameter
is
SqlParameter
)
{
((
SqlParameter
)
parameter
).
UdtTypeName
=
"GEOGRAPHY"
;
}
}
/// <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
SqlGeography
Parse
(
object
value
)
{
return
value
as
SqlGeography
;
}
}
}
Dapper.SqlBuilder/Properties/AssemblyInfo.cs
View file @
54bc52b3
...
...
@@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.3
1
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.3
1
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.3
2
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.3
2
.0.0"
)]
DapperTests NET35/Properties/AssemblyInfo.cs
View file @
54bc52b3
...
...
@@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.3
1
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.3
1
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.3
2
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.3
2
.0.0"
)]
DapperTests NET45/Properties/AssemblyInfo.cs
View file @
54bc52b3
...
...
@@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.3
1
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.3
1
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.3
2
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.3
2
.0.0"
)]
Tests/Properties/AssemblyInfo.cs
View file @
54bc52b3
...
...
@@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.3
1
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.3
1
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.3
2
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.3
2
.0.0"
)]
Tests/Tests.cs
View file @
54bc52b3
...
...
@@ -3012,8 +3012,7 @@ public void DBGeography_SO24405645_SO24402424()
public
void
SqlGeography_SO25538154
()
{
Dapper
.
EntityFramework
.
Handlers
.
Register
();
Dapper
.
SqlMapper
.
ResetTypeHandlers
();
connection
.
Execute
(
"create table #SqlGeo (id int, geo geography)"
);
var
obj
=
new
HazSqlGeo
...
...
@@ -3022,7 +3021,7 @@ public void SqlGeography_SO25538154()
Geo
=
SqlGeography
.
STLineFromText
(
new
SqlChars
(
new
SqlString
(
"LINESTRING(-122.360 47.656, -122.343 47.656 )"
)),
4326
)
};
connection
.
Execute
(
"insert #SqlGeo(id, geo) values (@Id, @Geo)"
,
obj
);
var
row
=
connection
.
Query
<
HazGeo
>(
"select * from #SqlGeo where id=1"
).
SingleOrDefault
();
var
row
=
connection
.
Query
<
Haz
Sql
Geo
>(
"select * from #SqlGeo where id=1"
).
SingleOrDefault
();
row
.
IsNotNull
();
row
.
Id
.
IsEqualTo
(
1
);
row
.
Geo
.
IsNotNull
();
...
...
Tests/app.config
View file @
54bc52b3
...
...
@@ -22,4 +22,12 @@
<
provider
invariantName
=
"System.Data.SqlClient"
type
=
"System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"
/>
</
providers
>
</
entityFramework
>
<
runtime
>
<
assemblyBinding
xmlns
=
"urn:schemas-microsoft-com:asm.v1"
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"Microsoft.SqlServer.Types"
publicKeyToken
=
"89845dcd8080cc91"
/>
<
bindingRedirect
oldVersion
=
"10.0.0.0"
newVersion
=
"11.0.0.0"
/>
</
dependentAssembly
>
</
assemblyBinding
>
</
runtime
>
</
configuration
>
\ No newline at end of file
dapper.nuspec
View file @
54bc52b3
...
...
@@ -2,7 +2,7 @@
<package
xmlns=
"http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"
>
<metadata
schemaVersion=
"2"
>
<id>
Dapper
</id>
<version>
1.3
1
</version>
<version>
1.3
2
</version>
<title>
Dapper dot net
</title>
<authors>
Sam Saffron,Marc Gravell
</authors>
<owners>
Sam Saffron,Marc Gravell
</owners>
...
...
@@ -19,6 +19,7 @@
<frameworkAssembly
assemblyName=
"Microsoft.CSharp"
targetFramework=
".NETFramework4.0-Client, .NETFramework4.0"
/>
</frameworkAssemblies>
<releaseNotes>
* 1.32 - Support for SqlGeography in core library
* 1.31 - Fix issue with error message when there is a column/type mismatch
* 1.30 - Better async cancellation
* 1.29 - Make underscore name matching optional (opt-in) - this can be a breaking change for some people
...
...
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