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
Error when trying to insert to Geography column using IPropertyHandler.
I have verified that the lat/lng being passed are correct and valid.
The Set method in the property handler is hit when debugging and returns a valid looking SqlGeography object.
The Get method in the property handler works fine.
I am able to use lat/lng manually by inserting the values into float columns and then updating the Geography column from those directly:
UPDATE leads.lead
SET geolocation=geography::Point(lat, lng, 4326)
WHERE LeadId=146893;
Exception Message:
System.InvalidCastException: Failed to convert parameter value from a SqlGeography to a String.---> System.InvalidCastException: Object must implement IConvertible.atSystem.Convert.ChangeType(Objectvalue,TypeconversionType,IFormatProviderprovider)
at Microsoft.Data.SqlClient.SqlParameter.CoerceValue(Objectvalue,MetaTypedestinationType,Boolean&coercedToDataFeed,Boolean&typeChanged,BooleanallowStreaming)---End of inner exception stack trace ---at Microsoft.Data.SqlClient.SqlParameter.CoerceValue(Objectvalue,MetaTypedestinationType,Boolean&coercedToDataFeed,Boolean&typeChanged,BooleanallowStreaming)
at Microsoft.Data.SqlClient.SqlParameter.GetCoercedValue()
at Microsoft.Data.SqlClient.SqlParameter.Validate(Int32index,BooleanisCommandProc)
at Microsoft.Data.SqlClient.SqlCommand.BuildParamList(TdsParserparser,SqlParameterCollectionparameters,BooleanincludeReturnValue)
at Microsoft.Data.SqlClient.SqlCommand.BuildExecuteSql(CommandBehaviorbehavior,StringcommandText,SqlParameterCollectionparameters,_SqlRPC&rpc)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehaviorcmdBehavior,RunBehaviorrunBehavior,BooleanreturnStream,BooleanisAsync,Int32timeout,Task&task,BooleanasyncWrite,BooleaninRetry,SqlDataReaderds,BooleandescribeParameterEncryptionRequest)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehaviorcmdBehavior,RunBehaviorrunBehavior,BooleanreturnStream, TaskCompletionSource`1completion,Int32timeout,Task&task,Boolean&usedCache,BooleanasyncWrite,BooleaninRetry,Stringmethod)
at Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReaderInternal(CommandBehaviorbehavior,AsyncCallbackcallback,ObjectstateObject,Int32timeout,BooleaninRetry,BooleanasyncWrite)
at Microsoft.Data.SqlClient.SqlCommand.<>c.<InternalExecuteReaderAsync>b__201_0(AsyncCallbackcallback,ObjectstateObject)
at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl(Func`3beginMethod, Func`2endFunction, Action`1endAction,Objectstate,TaskCreationOptionscreationOptions)
at System.Threading.Tasks.TaskFactory`1.FromAsync(Func`3beginMethod, Func`2endMethod,Objectstate)
at Microsoft.Data.SqlClient.SqlCommand.InternalExecuteReaderAsync(CommandBehaviorbehavior,CancellationTokencancellationToken)---Endof stack trace from previous location ---at RepoDb.DbConnectionExtension.InsertAsyncInternalBase[TEntity,TResult](IDbConnectionconnection,StringtableName,TEntityentity, IEnumerable`1fields,Stringhints, Nullable`1commandTimeout,StringtraceKey,IDbTransactiontransaction,ITracetrace,IStatementBuilderstatementBuilder,CancellationTokencancellationToken)
at Tvd.Leads.Infrastructure.Repositories.Leads.SaveLeadCommandHandler.Handle(SaveLeadCommandrequest,CancellationTokencancellationToken)in C:\Projects\Tvd.Leads\Tvd.Leads.Infrastructure\Repositories\Leads\SaveLead.cs:line 28
at Tvd.Leads.Infrastructure.Repositories.Leads.SaveLeadCommandHandler.Handle(SaveLeadCommandrequest,CancellationTokencancellationToken)in C:\Projects\Tvd.Leads\Tvd.Leads.Infrastructure\Repositories\Leads\SaveLead.cs:line 55
at Tvd.Leads.Infrastructure.Repositories.Leads.SaveLeadCommandHandler.Handle(SaveLeadCommandrequest,CancellationTokencancellationToken)in C:\Projects\Tvd.Leads\Tvd.Leads.Infrastructure\Repositories\Leads\SaveLead.cs:line 55
at Tvd.Leads.Application.LeadServiceBase.SaveLeadAndHandleLeadEvents(Leadlead,CancellationTokenct)in C:\Projects\Tvd.Leads\Tvd.Leads.Application\LeadServiceBase.cs:line 19
at Tvd.Leads.Application.CreateLeadService.Create(CreateLeadModelmodel,CancellationTokenct)in C:\Projects\Tvd.Leads\Tvd.Leads.Application\CreateLeadService.cs:line 48
at Tvd.Leads.Api.Controllers.LeadController.Create(CreateLeadModelmodel)in C:\Projects\Tvd.Leads\Tvd.Leads.Api\Controllers\LeadController.cs:line 16
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(ActionContextactionContext,IActionResultTypeMappermapper,ObjectMethodExecutorexecutor,Objectcontroller,Object[]arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvokerinvoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvokerinvoker,TasklastTask,Statenext,Scopescope,Objectstate,BooleanisCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealedcontext)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State&next,Scope&scope,Object&state,Boolean&isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvokerinvoker,TasklastTask,Statenext,Scopescope,Objectstate,BooleanisCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvokerinvoker,TasklastTask,Statenext,Scopescope,Objectstate,BooleanisCompleted)
at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilder.<>c.<<BuildPipeline>b__8_0>d.MoveNext()---Endof stack trace from previous location ---at Tvd.Leads.Api.Infrastructure.ApiKeyAuthorisation.Invoke(HttpContextcontext)in C:\Projects\Tvd.Leads\Tvd.Leads.Api\Infrastructure\ApiKeyAuthorisation.cs:line 28
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvokerinvoker,TasklastTask,Statenext,Scopescope,Objectstate,BooleanisCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvokerinvoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvokerinvoker)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContextcontext)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContextcontext)
Schema and Model:
It's just a single Geography column, other columns are unrelated,
Bug Description
Error when trying to insert to Geography column using
IPropertyHandler
.SqlGeography
object.Exception Message:
Schema and Model:
It's just a single Geography column, other columns are unrelated,
The insert looks like this:
the dto is rather long, but the relevant column looks like this:
And this is the handler
Library Version:
RepoDb v1.13.1 and RepoDb.SqlServer v1.13.1
The text was updated successfully, but these errors were encountered: