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

  • SEARCH
  • Home
  • 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 185533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:29:12+00:00 2026-05-11T15:29:12+00:00

I have a base class that declares a private non-static reference to the DataBase

  • 0

I have a base class that declares a private non-static reference to the DataBase Handler instance (DBH).

DBH is a class we use to simplify database operations of derived classes. It contains the usual methods, like ExecuteScalar, StartTransaction among others; and it provides additional benefits in the application context, like caching and zero configuration.

Instances of derived classes use DBH to read/save its state in the database, and since their operations are not atomic, all derived classes use this transaction. Everything is going on in one place: a virtual method called InsertUpdate() declared in the base class.

Next, I have a collection (called Book) of instances of derived classes. I want to take collection updates as transaction.

I want to achieve something similar to this:

DatabaseHandler dbh = new DatabaseHandler()  t = dbh.StartTrasaction(); foreach( Type o in Book<Type> )  {     o.prop1 = ..     o.prop2 = ...     o.method1() ...      o.InsertUpdate(t);  // uses its own instance of DatabaseHandler and starts its own transaction } dbh.EndTransaction(t); 

Currently the InsertUpdate method is parameter-less. I guess I’ll have to introduce an overloaded version which accepts a transaction object.

Besides solving my current issue, are there any design issues I need to know about? How can I improve this design or institute a better design?

  • 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-11T15:29:12+00:00Added an answer on May 11, 2026 at 3:29 pm

    Make sure you read this question

    Personally, I usually go with ‘my own’ implementation of a TrasactionScope like object that wacks data on to TLS with the added benefit of having a factory that allows for easy profiling and logging.

    To me your current design sound fairly complex. By decoupling your raw database access code from your classes it will reduce duplication (and avoid requiring all your data access classes inherit off a base class). Defining an object as opposed to a set of static methods for DB access will ease testing (you can substitute a mock class)

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

Sidebar

Ask A Question

Stats

  • Questions 111k
  • Answers 111k
  • 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
  • Editorial Team
    Editorial Team added an answer Only if you want to make sure you get a… May 11, 2026 at 9:45 pm
  • Editorial Team
    Editorial Team added an answer it may be a crossdomain.xml issue. Try placing a crossdomain.xml… May 11, 2026 at 9:45 pm
  • Editorial Team
    Editorial Team added an answer This should do it - I set it up so… May 11, 2026 at 9:45 pm

Related Questions

I have a class, lets call it A, and within that class definition I
When implementing IDisposable correctly, most implementations, including the framework guidelines, suggest including a private
I am trying to create an app in Qt/C++ with Qt4.5 and want the
I have an abstract base class and I want to declare a field or
I have a base class which is non-generic with a derived generic class. The

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.