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 232305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:00:22+00:00 2026-05-11T20:00:22+00:00

I have two repository classes below, MoneyTransferRepository class is used by other classes in

  • 0

I have two repository classes below,
MoneyTransferRepository class is used by other classes in my project. I have designed it this way – is it right? If not, what is the best way?

Thanks

public interface IMoneyTransferRepository
{
    void UpdateBalance();
}

public interface IOrderRepository
{
    void Checkout();
    void SaveOrder();
}

public class MoneyTransferRepository : IMoneyTransferRepository
{
    DBDataContext DB;

    public MoneyTransferRepository(IDbConnection connection)
    {
        DB = new DBDataContext(connection);
    }

    public void UpdateBalance()
    {
        //do something DB.Table1.Update
    }

}


public class OrderRepository : IOrderRepository,IMoneyTransferRepository
{

    DBDataContext DB;
    IMoneyTransferRepository moneyTransferRepository;

    public OrderRepository()
    {
        DB = new DBDataContext();
        moneyTransferRepository = new MoneyTransferRepository(DB.Connection);
    }

    public void Checkout()
    {
        TransactionOptions transactionOptions = new TransactionOptions();
        transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;

        using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
        {
            try
            {
                UpdateBalance();
                SaveOrder();
                transactionScope.Complete();
            }
            catch
            {

            }

        }
    }

    public void UpdateBalance()
    {
        moneyTransferRepository.UpdateBalance();
    }

    public void SaveOrder()
    {
        //do something DB.SaveOrder.Update ......
        //   DB.Updatestock .....

    }
}
  • 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. Editorial Team
    Editorial Team
    2026-05-11T20:00:22+00:00Added an answer on May 11, 2026 at 8:00 pm

    Don’t do transaction management in Repository. Thats why you get confused.

    More info is here:
    Transactions in the Repository Pattern

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

Sidebar

Related Questions

Say I have two separate classes, A and B. I also have Repository class
I have two classes derived from BankAccount class – FixedBankAccount and SavingsBankAccount. This is
I have two classes (MVC view model) which inherits from one abstract base class.
I have two Classes (i.e. Customer , and Employee ) and a generic repository
I have two simple POCO classes; I'm trying to get the MyY property below
I have two repository classes ( RepositoryFactory and BaseRepository ) implementing different interfaces within
Lets say I have two classes: public class A { public virtual int Id
I have the following code to manage two kinds of repositories. Both repository classes
I have a git repository (at github.com) with two branches: master and gh-pages. I
I'm working in an ASP.NET MVC project where I have created a two LinqToSQL

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.