I haven't actually looked at this error too often, but I believe I need to trap this condition in one particular query in my application. We are expecting our software to be installed on some slow syistems with only 500 MB of RAM. I'm expecting that this one particular query is going to time out a lot and I need to handle the condition properly. Unfortunately, my workstation has 4 GB and 2 cores and is clocked at almost 3 GHz.
SO what exactly do I need to catch and how do I know for sure that it's a timeout exception?
BTW, the query is generated using an Entity Framework 4.0 context developed using Entity Developer. We're using build 5.80.350.0.
Tony
What is the exact exception and message that is thrown if a query times out?
Re: What is the exact exception and message that is thrown if a query times out?
1. An example of handling PostgreSQL timeout exception via Entity Framework:TonyV wrote:SO what exactly do I need to catch and how do I know for sure that it's a timeout exception?
Code: Select all
using (PostgreEntities context = new PostgreEntities()) {
context.CommandTimeout = 1;
try {
var a = (from b in context.Mytbls.Union(context.Mytbls).Union(context.Mytbls)
select b).ToList(); // execution time > 1 second
}
catch (EntityException ex) {
if (ex.InnerException is Devart.Data.PostgreSql.PgSqlException && ex.InnerException.Message == "Server did not respond within the specified timeout interval.") {
// process the timeout exception
}
}
}
Re: What is the exact exception and message that is thrown if a query times out?
Thank you for the response. Now to run with it.