I use FSharp.Data.SqlClient type providers to access SQL server database. So, I set up the types in F# something as follows:
type ClmDB = SqlProgrammabilityProvider<ClmSqlProviderName, ConfigFile = AppConfigFile>
type ResultDataTable = ClmDB.dbo.Tables.ResultData
type ResultDataTableRow = ResultDataTable.Row
and then I use it something like that:
let saveResultData (r : ResultData) (conn : SqlConnection) =
let t = new ResultDataTable()
let newRow = r.addRow t
t.Update(conn) |> ignore
newRow.resultDataId
where ResultData is some type, which "knows" how to convert itself into a row of ResultDataTable (ResultDataTableRow). The extension r.addRow t does that.
Everything is great, except that the row that I am inserting might be fairly large (25-30 MB in size) and so, I have a bad feeling that t.Update(conn) might randomly time out especially due to nearly 100% processor load (the computational system core is designed to consume all processing resources, though at low priority). Hovering over t.Update does not show any way to specify a timeout and any timeout at the level of connection is related, well, to a connection, not to the insert transaction ☹.
So, the question is how to specify timeout for an Update transaction.
Thanks a lot!
20190116 update - So far t.Update(conn) above is holding up without timeouts on my machine while inserting 95MB data rows at 100% below normal load of some other stuff running there. I have not yet measured the actual time for such transactions. If I do, then I will update this.
You cannot specify timeout for
Updatemethod of a providedDataTablebecause the current Type Provider implementation does not provision for such feature.However, as the documentation notes you may have few options for customizing the default behavior.
In addition, as your use case resembles an insert of a single row into the table I'd stick to an implementation with the help of
SqlCommandProviderusing its constructor'scommandTimeOutoptional parameter for setting the desired timeout valuetimespan, as in a snippet below: