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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:03:51+00:00 2026-05-23T16:03:51+00:00

I’ve started maintaining an application, which comes with a big database, which is partly

  • 0

I’ve started maintaining an application, which comes with a big database, which is partly not normalized / pretty messy. A lot of duplicate data and some tables with lots of fields (30+). For example, I’ve got a table called Orders which contains lots of fields. I’d go and split this table up, but changes to the database layout are not allowed. Now, if I stick to the repository pattern for example, I believe I should be creating an Order entity and the CRUD methods for it. The problem is, that the business logic almost never requires the entire Order Entity to be loaded/updated, but only a subset. That would make up a lot of Entities (like FullOrder, OrderMetaInfo, OrderProcessingDetails, and so on).

My question is, what would be the best way to deal with this kind of database-mess? I was thinking of creating a simple class called Orders, the Entities mentioned before as POCOs and than have methods like UpdateOrderMetaInfo() or GetOrderProcessingDetails(). Thats seems to be a pretty good way until you start thinking about, that there are two tables, one is Orders and the other one ArchivedOrders (and no, the fields are not identical but very similar – don’t even ask). It seems that I’ll be running in a huge amount of duplicate code. Now I’m starting to think about writing a really simple database access class, where you pass in a handmade sql query and get back a recordsset, as in the good old days. Do you have a better idea than this?

Facts and Limits: It is an Sql Database and the project is written in C#. There is another system using the same database, so changing the database layout is not an option. Using EF or any 3rd party product for data access is not an option, too.

Sorry for the extensively long post and thanks for your feedback.

  • 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-23T16:03:51+00:00Added an answer on May 23, 2026 at 4:03 pm

    Why don’t you just use the property setters to actually “mark” what needs to be updated.

    For example, a user may do

    Order.Client = "Jorge";
    Order.Price = 300;
    Order.Provider = "Microsoft";
    

    then your setter will look like

    public string Client{
    set
    {
      mClient = value;
      ModifiedFields.Add("ClientField");
    }
    

    and finally your Update method will decide, based on the ModifiedFields information the actual query that needs to be run in order to update the modified fields.

    To actually retreive data you can simply have a general GetOrder() method if the query is not that slow, or… if it really weights enough to kill your performance have the getter for each property retrieve the needed information for a given subset of the data, either by having a caching policy or by providing a GetLastValue to the property.

    Example:

    public class DBField<T>
    {
      private DBCommand getCommand;
    
      public T Value {get;set;}
      public T GetLastValue()
      {
         // Execute getCommand here
      }
    
      public DBField<T>(DBCommand GetCommand)
      {
        this.getCommand = GetCommand;
      }
    }
    

    I user will then do:

    string Client = Orders["Id"].Client.GetLastValue();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.