Saving TimeSpan into SQL Server 2012 as a Time column with ServiceStack OrmLite and C# -


i have time(7) column in database table, , want save timespan using c# , ormlite object relational mapper. while performing action exception

operand type clash: bigint incompatible time

this server stack trace;

[updatejobfrequency: 11/07/2015 5:43:39 am]: [request: {jobfrequency:{id:0,jobid:3,frequencyid:2,instanceoffrequency:1,time:pt1h,weeknumber:0}}] system.data.sqlclient.sqlexception (0x80131904): operand type clash: bigint incompatible time    @ system.data.sqlclient.sqlconnection.onerror(sqlexception exception, boolean breakconnection, action`1 wrapcloseinaction)    @ system.data.sqlclient.tdsparser.throwexceptionandwarning(tdsparserstateobject stateobj, boolean callerhasconnectionlock, boolean asyncclose)    @ system.data.sqlclient.tdsparser.tryrun(runbehavior runbehavior, sqlcommand cmdhandler, sqldatareader datastream, bulkcopysimpleresultset bulkcopyhandler, tdsparserstateobject stateobj, boolean& dataready)    @ system.data.sqlclient.sqldatareader.tryconsumemetadata()    @ system.data.sqlclient.sqldatareader.get_metadata()    @ system.data.sqlclient.sqlcommand.finishexecutereader(sqldatareader ds, runbehavior runbehavior, string resetoptionsstring)    @ system.data.sqlclient.sqlcommand.runexecutereadertds(commandbehavior cmdbehavior, runbehavior runbehavior, boolean returnstream, boolean async, int32 timeout, task& task, boolean asyncwrite, sqldatareader ds)    @ system.data.sqlclient.sqlcommand.runexecutereader(commandbehavior cmdbehavior, runbehavior runbehavior, boolean returnstream, string method, taskcompletionsource`1 completion, int32 timeout, task& task, boolean asyncwrite)    @ system.data.sqlclient.sqlcommand.runexecutereader(commandbehavior cmdbehavior, runbehavior runbehavior, boolean returnstream, string method)    @ system.data.sqlclient.sqlcommand.executescalar()    @ servicestack.ormlite.ormlitecommand.executescalar()    @ servicestack.ormlite.ormlitereadcommandextensions.longscalar(idbcommand dbcmd)    @ servicestack.ormlite.ormliteresultsfilterextensions.execlongscalar(idbcommand dbcmd, string sql)    @ servicestack.ormlite.ormlitedialectproviderbase`1.insertandgetlastinsertid[t](idbcommand dbcmd)    @ servicestack.ormlite.ormlitewritecommandextensions.insert[t](idbcommand dbcmd, t obj, boolean selectidentity)    @ servicestack.ormlite.ormlitewriteapi.<>c__displayclass4`1.<insert>b__3(idbcommand dbcmd)    @ servicestack.ormlite.ormliteexecfilter.exec[t](idbconnection dbconn, func`2 filter)    @ servicestack.ormlite.ormlitereadexpressionsapi.exec[t](idbconnection dbconn, func`2 filter)    @ servicestack.ormlite.ormlitewriteapi.insert[t](idbconnection dbconn, t obj, boolean selectidentity)    @ jobrepositorybase.<create>d__a`1.movenext() in c:\dev\repositorybase.cs:line 89 --- end of stack trace previous location exception thrown ---    @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task)    @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task)    @ system.runtime.compilerservices.taskawaiter`1.getresult()    @ job.webapphost.service.jobfrequencyservice.<post>d__6.movenext() in c:\dev\jobfrequencyservice.cs:line 30 

i passing 01:00:00 timespan value interface showing time: pt1h in object @ server side.

also, have read in 1 of stack overflow questionnaire ado.net timespan mapped sql server time(7). , believe servicestack ormlite built upon ado.net. however, in case facing exception.

any highly appreciated.

due urgency, had workaround problem, had change data type of table bigint. so, ormlite doing mapping bigint timespan , vice versa - github, can store , retrieve field without problem.

but still believe not perfect solution in case developing database scratch, in case has use existing database, workaround fails.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -