bevarse Posted November 6, 2014 Report Posted November 6, 2014 Bhayya, I wrote a method that will be doing this private void method1(List<object>updates) { using (var context = DbFactory.Initialize<DBEntities>()) { using (DbTransaction tx = context.BeginTransaction()) { //Perform some inserts context.GuardSaveChanges(); tx.Commit(); } } using (var context = DbFactory.Initialize<DBEntities>()) { using (DbTransaction tx = context.BeginTransaction()) { //Perform some updates context.GuardSaveChanges(); tx.Commit(); } } }
bevarse Posted November 6, 2014 Author Report Posted November 6, 2014 Reviwe cheyyamani team ki email chesa, okadu said this: if first transaction throws an error will id try to go to the second step and do the second transaction ? if yes then we will get 2 errors kada annadu is there a better way to code this ? the reason for 2 transactions is: first transaction lo oka insert chestunnam, we are passing that value to a different service in the second transaction first di commit avvakapote the service is throwing an error (cant fetch value from DB ani)
zerokool1290 Posted November 6, 2014 Report Posted November 6, 2014 first daantlo error vasthe second daaniki velladu. it crashes. Have Try catch blocks
aakpak_karepak007 Posted November 6, 2014 Report Posted November 6, 2014 first daantlo error vasthe second daaniki velladu. it crashes. Have Try catch blocks Using is translated as try catch and will call dispose if an exception occurs.. Exception record cheyyali inkemaina cheyyali ante use try catch finally...
zerokool1290 Posted November 6, 2014 Report Posted November 6, 2014 Using is translated as try catch and will call dispose if an exception occurs.. Exception record cheyyali inkemaina cheyyali ante use try catch finally... good to know. Thanks just confirming what you just said - http://stackoverflow.com/questions/8309877/if-an-exception-happens-within-a-using-statement-does-the-object-still-get-dispo
bevarse Posted November 6, 2014 Author Report Posted November 6, 2014 Using is translated as try catch and will call dispose if an exception occurs.. Exception record cheyyali inkemaina cheyyali ante use try catch finally... Bhayya, here is the code. Is this what you wanted me to do ?? nenu first paste chesina code is called from this originalmethod public void originalmethod(updates) { try { method1(updates) } catch (Exception ex) { ExceptionPolicy.HandleException(ex, "Legacy Exception Policy"); ServiceLogger.LogError(OpName, ex); } finally { LegacyExceptionHelper.ClearExternalServiceRequestsAndResponsesFromThreadContext(); } }
aakpak_karepak007 Posted November 6, 2014 Report Posted November 6, 2014 Bhayya, here is the code. Is this what you wanted me to do ?? nenu first paste chesina code is called from this originalmethod public void originalmethod(updates) { try { method1(updates)} catch (Exception ex) { ExceptionPolicy.HandleException(ex, "Legacy Exception Policy"); ServiceLogger.LogError(OpName, ex); } finally { LegacyExceptionHelper.ClearExternalServiceRequestsAndResponsesFromThreadContext(); } } Method lo using lopala try catch pettu rather than wrapping the method inside try catch..
karna11 Posted November 6, 2014 Report Posted November 6, 2014 Method lo using lopala try catch pettu rather than wrapping the method inside try catch.. Agreed
bevarse Posted November 6, 2014 Author Report Posted November 6, 2014 Agreed first using lo oka try catch and second using lo oka try catch pettala ?
karna11 Posted November 6, 2014 Report Posted November 6, 2014 first using lo oka try catch and second using lo oka try catch pettala ? 2 using loo pettali, rendu commit lu vaduthunnav kabatti
Recommended Posts