Graham, We use ICriteria and IQuery quite a lot. I need to centralize the retry logic so that if connection is lost, it should be re-established and retried. I am looking for a common set of methods that can take a prepared ICrietria or a prepared IQuery object and execute it and then retry upto maximum number of attempts if needed. Do you have some code that you could share. We have a dozens of data access object that execute IQuery and ICriteria for various mapped classes that could benefit from retry logic. Instead of putting retry logic in all methods of those DAO's, I would rather have centralized methods to ExecuteCriteria or ExecuteQuery that incorporate the retry logic.
I would appreciate if you or somebody else could share some code that does that. Thanks. Waqar On Wednesday, October 14, 2009 11:55:20 AM UTC-5, Graham Bunce wrote: > > All, > > In my application I have a repository layer which wraps access to > database queries. As NH-Linq has come on the scene we've started using > his a lot more for new apps. > > However, as Linq queries are deferred until first use, I'm not sure > how to deal with common DB errors that can be retried - i.e. DB > deadlock, timeout, connection lost etc. > > With NH Queries it's quite easy. I have a "QueryProcessor" that has > methods such as UniqueResult, List etc. and accepts an NH IQuery or > IMultiQuery. The logic then wraps the actual query call with retry > logic. > > This way I have a common QueryProcessor for all my Repository queries. > > I'm a little stuck as to how to implement this pattern for Linq > though... I can wrap the logic around every Linq query but then I have > tons of replicated code. Can I use IQueryable in the same way as > IQuery ? > > Do I have to inject an IQueryable<T> into my method and then do a > ToList() to force the query to run within my retry logic? > > Is there another way.. as I may end up using things like > SingleOrDefault(), First() etc instead and I'd rather not replicate > all these Linq functions as QueryProcessor method calls. > > Any advice appreciated -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.
