Commit a8043e02 authored by Marc Gravell's avatar Marc Gravell

only attempt to set UdtTypeName after checking parameter type

parent e26ee0ab
...@@ -2941,8 +2941,11 @@ class GeographyMapper : Dapper.SqlMapper.TypeHandler<DbGeography> ...@@ -2941,8 +2941,11 @@ class GeographyMapper : Dapper.SqlMapper.TypeHandler<DbGeography>
public override void SetValue(IDbDataParameter parameter, DbGeography value) public override void SetValue(IDbDataParameter parameter, DbGeography value)
{ {
parameter.Value = value == null ? (object)DBNull.Value : (object)SqlGeography.Parse(value.AsText()); parameter.Value = value == null ? (object)DBNull.Value : (object)SqlGeography.Parse(value.AsText());
if(parameter is SqlParameter)
{
((SqlParameter)parameter).UdtTypeName = "GEOGRAPHY"; ((SqlParameter)parameter).UdtTypeName = "GEOGRAPHY";
} }
}
public override DbGeography Parse(object value) public override DbGeography Parse(object value)
{ {
return (value == null || value is DBNull) ? null : DbGeography.FromText(value.ToString()); return (value == null || value is DBNull) ? null : DbGeography.FromText(value.ToString());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment