简体   繁体   English

F# - FSharp.Data.SqlClient - 如何指定更新超时

[英]F# - FSharp.Data.SqlClient – How to specify timeout for Update

I use FSharp.Data.SqlClient type providers to access SQL server database.我使用FSharp.Data.SqlClient类型提供程序来访问 SQL 服务器数据库。 So, I set up the types in F# something as follows:所以,我在 F# 中设置类型如下:

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 ).其中ResultData是某种类型,它“知道”如何将自己转换为一行ResultDataTable ( ResultDataTableRow )。 The extension r.addRow t does that.扩展名r.addRow t这样做的。

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).一切都很好,除了我插入的行可能相当大(大小为 25-30 MB),因此,我有一种不好的感觉t.Update(conn)可能会随机超时,特别是由于接近 100% 的处理器负载(计算系统核心旨在消耗所有处理资源,尽管优先级较低)。 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 ☹.将鼠标悬停在t.Update上不会显示任何指定超时的方法,并且连接级别的任何超时都与连接相关,而不是与插入事务☹有关。

So, the question is how to specify timeout for an Update transaction.所以,问题是如何为Update事务指定超时。

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. 20190116更新 - 到目前为止,上面的t.Update(conn)在我的机器上没有超时,同时插入 95MB 数据行,低于在那里运行的其他一些东西的正常负载的 100%。 I have not yet measured the actual time for such transactions.我尚未测量此类交易的实际时间。 If I do, then I will update this.如果我这样做,那么我会更新这个。

You cannot specify timeout for Update method of a provided DataTable because the current Type Provider implementation does not provision for such feature.您不能为提供的DataTable Update方法指定超时,因为当前的类型提供程序实现不提供此类功能。

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 SqlCommandProvider using its constructor's commandTimeOut optional parameter for setting the desired timeout value timespan , as in a snippet below:此外,由于你的使用情况类似于一个单列的插入到表中我会坚持的帮助下实现SqlCommandProvider使用其构造的commandTimeOut可选参数设置所需的超时值timespan ,如下面的代码段:

type AddRow = SqlCommandProvider<"path to the parameterized INSERT statement", designTimeConnection> 
..............................
(new AddRow(runTimeConnection, commandTimeOut=timespan)).Execute(...arg=value...) |> ignore

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 F#FSharp.Data.SqlClient无法识别存储过程中的多个返回表 - F# FSharp.Data.SqlClient not recognizing multiple return tables from Stored Procedure 具有多个结果集的FSharp.Data.SqlClient - FSharp.Data.SqlClient with multiple result sets 带有 dotnet 核心报告类型“SqlCommand”的 Windows 上的 FSharp.Data.SqlClient 不可用 - FSharp.Data.SqlClient on windows with dotnet core reports type 'SqlCommand' unavailable System.Data.SqlClient.SqlException(0x80131904):更新存储过程后发生超时过期 - System.Data.SqlClient.SqlException (0x80131904): Timeout expired occured after i update the stored procedure System.Data.SqlClient.SqlException:提交时超时 - System.Data.SqlClient.SqlException: Timeout expired on commit System.Data.SqlClient.SqlException:'执行超时已过期 - System.Data.SqlClient.SqlException: 'Execution Timeout Expired F#:将数据加载到SQL Server中时遇到问题 - F#: Trouble with loading data into SQL Server connectionString超时应该在ASP.NET应用程序中多长时间? 程序(SqlClient) - How long should the connectionString timeout be in ASP.NET applications? (sqlclient) System.Data.SqlClient.SqlException:超时已过期。 操作完成之前经过的超时时间或服务器未响应 - System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding 如何在F#中包含存储过程 - How to include a stored procedure in F#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM