Delayed LINQ to SQL Labels with Delay

I have a LINQ to SQL / Unity / ASP.NET MVC / SQL Server application hosted on Azure. I use Lazy Evaluation throughout the site. The application uses a TCP connection with SQL Server, and every time I get the error "Transport layer when sending a request to the server." SqlException.

Well, since the request becomes materialized when it is called later in the code, I cannot just wrap a specific piece of code with try / catch.

Is there a way I can handle this exception by implementing an interface or attaching a delegate to a DataContext?

+3
source share
2 answers

If you use results from linq as-is, you need to handle the error in the code that materializes the data. However, instead of simply directly outputting the results of the linq query, you can wrap it in an IEnumerable implementation of your own design that can freely perform any necessary error handling. Thus, code that consumes IEnumerable should not handle the exception.

+3
source

I think the only way to fix this is to wrap code that launches (materializes) a SQL server call in an attempt to catch.

0
source

Source: https://habr.com/ru/post/1724679/


All Articles