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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:51:12+00:00 2026-06-16T02:51:12+00:00

We are in the process of refactoring entire code base of an ASP.Net web

  • 0

We are in the process of refactoring entire code base of an ASP.Net web application. Almost the entire application is using sql statements from c# code to query database and the similiar sql statements are scattered across the entire codebase. The application is using Mimer database which is not a commonly used database.

What could be a good refactoring plan for such an application, specially for the data access layer so as to remove duplicate code ensuring DRY?

  • 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-06-16T02:51:14+00:00Added an answer on June 16, 2026 at 2:51 am

    Implement a layer of abstraction over the database implementation, such that your application calls methods like GetUser() and UpdateWidget() instead of IDbCommand.ExecuteReader() and friends.

    Those methods will exist on interfaces, one for each entity type.

    IUserRepository
    IWidgetRepository
    

    You should have one implementer of each interface for each database platform.

    MySqlUserRepository
    MySqlWidgetRepository
    
    MimerUserRepository
    MimerWidgetRepository
    

    Then create a factory class which dishes out instances of the correct implementing class of the requested entity type for the relevant database platform.

    The factory class should be instantiated with knowledge of what database platform the application is currently configured to use. It should use this information to choose which class to instantiate and return when asked.

    class RepoFactory
    {
        string _platform;
        public RepoFactory(string platform) { this._platform = platform; }
    
        public IUserRepository GetUserRepository()
        {
            if (_platform == "mysql") return new MySqlUserRepository();
            if (_platform == "mimer") return new MimerUserRepository();
            throw new NotSupportedException(_platform);
        }
    
        public IWidgetRepository GetWidgetRepository() // ...
    }
    

    Keep a reference to a single instance of your RepoFactory so that you only have to set it up once from configuration.

    Stick all the database platform-specific stuff in the implementer classes, job done. (You have all the queries you’ll need for Mimer already written – you just need to transplant them from your app into this new data layer.)

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

Sidebar

Related Questions

I'm on the process of refactoring a web application developed in jQuery Mobile. The
In the process of refactoring some code, I encountered several build errors such as
We are in the process of refactoring some code. There is a feature that
I'm in the process of refactoring a Flex application into a library project, and
I'm in the process of refactoring some code which includes moving folders around, and
I'm refactoring an existing (Ajax) Java Web application, which currently holds lots of its
When working with the Web Site style ASP.NET project, VS.NET will compile all the
I have heard that you can run an ASP.NET application and ASP.NET mvc application
I'm refactoring a Rails-based event registration application that has a checkout process that hits
So far, I have been manually refactoring code by using the find-and-replace operation %s:/stringiwanttoreplace/newstring/g

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.