Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 75173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:28:29+00:00 2026-05-10T20:28:29+00:00

I have an application that has many different types of objects that each persist

  • 0

I have an application that has many different types of objects that each persist themselves back to the db. This has worked fine so far without transactions and I’m not looking to go hog wild adding them. But there is an occasional need to start a transaction before a whole collection of the objects start updating to ensure that the database is only actually updated if all objects in the collection succeed.

For example, say I have a collection of apples. The command is issued to the collection to update all the apples. [transaction starting should be here] The each apples executes the code to update itself. [transaction commit/rollback should happen here].

The hitch I have is that each update is atomic right now (not explicitly wrapped in a transaction). I could pass an id to each ‘apple’ to identify a transaction that has been stashed in some kind of cache, but then there’s the risk that the cache would be invalidated mid-update and cause an unnecessary problem.

So what’s the best approach to this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:28:30+00:00Added an answer on May 10, 2026 at 8:28 pm

    First, I wouldn’t be handling the transactional logic in the page. Write a business class of some sort to do this – a service, a data utility class, something you can abstract away from ASP.Net.

    Next, you might look at using the TransactionScope class (in System.Transactions namespace, reference System.Transactions.dll) if you are using a database that can subscribe to distributed transaction like SQL Server.

    using(TransactionScope scope = new TransactionScope()) {   SaveObjectOne(); //these are just psuedo-code statements   SaveObjectTwo(); //replace these with your code that saves various objs   SaveObjectThree();   scope.Complete(); //this commits the transaction, unless exception throws } 

    TransactionScope implements IDisposable, so when using calls Dispose() the transaction will roll back if Complete() was never called. You do need to enable the Distributed Transaction Coordinator to use TransactionScope.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 68k
  • Answers 68k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer No, you can not embed out-of-browser silverlight into WPF. The… May 11, 2026 at 12:16 pm
  • added an answer Law of Demeter. Create a property on MyClass that exposes… May 11, 2026 at 12:16 pm
  • added an answer The point is that you never actually pass an object.… May 11, 2026 at 12:16 pm

Related Questions

I have an application that has many different types of objects that each persist
I have an application that has created a number of custom event log sources
I have an application that has Powershell 1 embedded into it, but we need
I have an application that has several objects (about 50 so far, but growing).
I have an application that has multiple states, with each state responding to input
I have an application that has to deal with getting special characters in its
I have an application that has a primary layout of portrait (it is fixed
Is tight looping in a program bad? I have an application that has two
I have an application that seems to throw exceptions only after the program has
I have an application running in tomcat that has a bunch of configuration files

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.