如何将命令超时绑定到 dbml(Linq-To-Sql 数据类)?

Jad*_*ias 4 .net database-connection linq-to-sql

I know that we cannot set the Command Timeout in the Connection String. So I put it in the MyDataContext constructor. But there are many constructors, this file is usually overwritten by the visual designer and it doesn't seems the right way to do that. How would you do that?

Jad*_*ias 6

我将代码放入构造函数中,但正确的方法是创建一个单独的文件并粘贴以下代码:

partial class DataClassesDataContext
{
    partial void OnCreated()
    {
        this.CommandTimeout = Settings.Default.CommandTimeout;
    }
}
Run Code Online (Sandbox Code Playgroud)