This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I'm just looking at a project I created a while back and have a problem/question. I'm wondering what property I can test to see if the context is actually connected to the database ? I have some code as below that creates a context using config settings in App.Config static class LaunchContext
There is then a simple Repository class with code similar to below : public static IList<Location> GetLocations() There is not any exception handling added as yet. If I run the code and the Server (SQL 2005) is not actually running, the program gets through to the "return uow.Locations..." line but never comes out again to the next line. No exception is thrown as far as I can tell, it's like it disappears in to a black hole. The first question is, what do I test to see if there is actually a connection beofre I get to this point and the second is, any idea what is going on here ?
|
|
|
We don't provide a way to test the connection status of a unit of work, though you can fudge one up using a custom connection strategy. Basically we open the connection as soon as it is needed, and close it when you dispose the UOW. So the way you know about connection errors is through exceptions rather than through manually testing the connection status (which would always be Open). I'm not sure exactly what's happening in your "black hole" scenario. I've seen this happen in some debugging scenarios (especially when using TestDriven.NET). Or it may just be something causing an unnaturally long timeout. Does the "black hole" occur only when debugging or does it occur when you run outside the debugger too? Does it occur only with LightSpeed or can you reproduce it using raw ADO.NET with the same connection string and transaction settings? Does SQL Profiler show you anything of interest? |
|
|
I checked the App.Config and the connect timeout was set to 0, which is the problem.Doh. Um *cough* it's been a while since I've delved in to C#, that's my excuse. Makes sense to not actually open the connection until the uow does something, which is why it never returns from that call. Many thanks for the info. I might just add a dummy selection of something simple on start up to test the connection as a workaraound for the moment. Cheers |
|