You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use the spatial types in the Unofficial.Microsoft.SqlServer.Types package. The following error occurs when trying to use an SqlGeography or SqlGeometry value in a query:
System.ArgumentException
HResult=0x80070057
Message=UdtTypeName property must be set for UDT parameters.
Source=System.Data.SqlClient
StackTrace:
at System.Data.SqlClient.SqlParameter.Validate(Int32 index, Boolean isCommandProc)
at System.Data.SqlClient.SqlCommand.BuildParamList(TdsParser parser, SqlParameterCollection parameters)
at System.Data.SqlClient.SqlCommand.BuildExecuteSql(CommandBehavior behavior, String commandText, SqlParameterCollection parameters, _SqlRPC& rpc)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite, String methodName)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at LinqToDB.Data.DataConnection.ExecuteNonQuery()
at LinqToDB.Linq.QueryRunner.NonQueryQuery(Query query, IDataContext dataContext, Expression expr, Object[] parameters)
at LinqToDB.Linq.QueryRunner.<>c__DisplayClass28_0.<SetNonQueryQuery>b__0(IDataContext db, Expression expr, Object[] ps)
at LinqToDB.Linq.ExpressionQuery`1.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
linq2db correctly sets SqlParameter.SqlDbType to Udt and SqlParameter.TypeName to Geography, however, it does not set SqlParameter.UdtTypeName which causes the exception. The reason is the following code from the SqlServerDataProvider class:
I am trying to use the spatial types in the
Unofficial.Microsoft.SqlServer.Types
package. The following error occurs when trying to use anSqlGeography
orSqlGeometry
value in a query:linq2db correctly sets
SqlParameter.SqlDbType
toUdt
andSqlParameter.TypeName
toGeography
, however, it does not setSqlParameter.UdtTypeName
which causes the exception. The reason is the following code from theSqlServerDataProvider
class:https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/DataProvider/SqlServer/SqlServerDataProvider.cs
Steps to reproduce
I used
SqlServerTools.AddUdtType
to register the types before opening a connection.Environment details
linq2db version: 2.4.0
Database Server: SQL Server 2016
Database Provider: Any SQL Server provider
Operating system: Windows 10
Framework version: .NET Core 2.1
The text was updated successfully, but these errors were encountered: