Is there an easy way to establish a new connection timeout LINQ to SQL and CSLA?

Is there an easy way to establish a new connection timeout LINQ to SQL and CSLA?

Old forum URL: forums.lhotka.net/forums/t/9070.aspx


sognibene@hess.com posted on Friday, June 11, 2010

Hi All,

My DataPortal_Fetch() sub looks like this:

Using ctx = ContextManager(Of MyDataContext).GetManager(MyDB)
 'code here
End Using

I'm using LINQ to SQL with stored procedures to get my data.  Things are going pretty well except when people do very big queries - SQL Server is just timing out when pulling really large datasets.  I found that I can call ctx.DataContext.CommandTimeout and increase it from the default of 30 seconds and this fixes the issue for me.

Using ctx = ContextManager(Of MyDataContext).GetManager(MyDB)
 ctx.DataContext.CommandTimeout = MyConfig.SQLCommandTimeout
 'rest of DB code here
End Using

However, I was wondering if there was some good way for me to put this into a config file and have the framework pick it up automatically rather than me having to find all my using ctx blocks and putting in the code to bump up the timeout.

Thanks!

-Steve O

sognibene@hess.com replied on Monday, June 14, 2010

Sorry for the bump, but I was wondering if the framework supports this or if I should set to editing all of my list objects...

sognibene@hess.com replied on Tuesday, June 15, 2010

It doesn't appear that this is supported in the framework I'm on, so I just started adding...

ctx.DataContext.CommandTimeout = MyConfig.SQLCommandTimeout

...to all my DataPortal routines.  The SQLCommandTimeout is read from the .config file.

Copyright (c) Marimer LLC