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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:15:05+00:00 2026-05-23T14:15:05+00:00

I have a two part application. One part is a web application (C# 4.0)

  • 0

I have a two part application. One part is a web application (C# 4.0) which runs on a hosted machine with a hosted MSSQL database. That’s nice and standard. The other part is a Windows Application that runs locally on our network and accesses both our main database (Advantage) and the web database. The website has no way to access the Advantage database.

Currently this setup works just fine (provided the network is working), but we’re now in the process of rebuilding the website and upgrading it from a Web Forms /.NET 2.0 / VB site to a MVC3 / .NET 4.0 / C# site. As part of the rebuild, we’re adding a number of new tables where the internal database has all the data, and the web database has a subset thereof.

In the internal application, tables in the database are represented by classes which use reflection and attribute flags to populate themselves. For example:

[AdvantageTable("warranty")]
public class Warranty : AdvantageTable
{
    [Advantage("id", IsKey = true)]
    public int programID;
    [Advantage("w_cost")]
    public decimal cost;
    [Advantage("w_price")]
    public decimal price;

    public Warranty(int id)
    {
        this.programID = id;
        Initialize();
    }
}

The AdvantageTable class’s Initialize() method uses reflection to build a query based on all the keys and their values, and then populates each field based on the database column specified. Updates work similarly – We call AdvantageTable.Update() on whichever object, and it handles all the database writes. It works quite well, hides all the standard CRUD, and lets us rapidly create new classes when we add a new table. We’d rather not change it, but I’m not going to entirely rule it out if there’s a solution that would require it.

The web database needs to have this table, but doesn’t have a need for the cost data. I could create a separate class that’s backed by the web database (via stored procedures, reflection, LINQ-TO-SQL, ADO data objects, etc), but there may be other functionality in the Warranty object which I want to behave the same way regardless of whether it’s called from the website or the internal app, without the need to maintain two sets of code. For example, we might change the logic of how we decide which warranty applies to a product – I want to need to create and test that in only one place, not two.

So my question is: Can anyone think of a good way to allow this class to sometimes be populated from the Advantage database and sometimes the web database? It’s not just a matter of connection strings, because they have two very different methods of access (even aside from the reflection). I considered adding [Web("id")] type tags to the Advantage tags, and only putting them on the fields which exist in the web database to designate its columns, then having a switch of some kind to control which set of logic is used for reading/writing, but I have the feeling that that would get painful (Is this method web-safe? How do I set the flag before instantiating it?). So I have no ideas I like and suspect there’s a solution I’m not even aware exists. Any input?

  • 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-23T14:15:05+00:00Added an answer on May 23, 2026 at 2:15 pm

    The solution I eventually came up with was two-fold. First, I used Linq-to-sql to generate objects for each web table. Then, I derived a new class from AdvantageTable called AdvantageWebTable<TABLEOBJECT>, which contains the web specific code, and added web specific attributes. So now the class looks like this:

    [AdvantageTable(“warranty”)]

    public class Warranty : AdvantageWebTable<WebObjs.Warranty>
    {
        [Advantage("id", IsKey = true)][Web("ID", IsKey = true)]
        public int programID;
        [Advantage("w_cost")][Web("Cost")]
        public decimal cost;
        [Advantage("w_price")][Web("Price")]
        public decimal price;
    
        public Warranty(int id)
        {
            this.programID = id;
            Initialize();
        }
    }
    

    There’s also hooks for populating web-only fields right before saving to the web database, and there will be (but isn’t yet since I haven’t needed it) a LoadFromWeb() function which uses reflection to populate the fields.

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

Sidebar

Related Questions

Background Information: I'm part of a team of developers that runs a web application
I have one web application with two projects: Project Website Using CMS; namespace Web
In my web application I have a part which needs to continuously crawl the
I have a two part question Best-Practice I have an algorithm that performs some
So let's say I have two different functions. One is a part of the
Background information Let's say I have two database servers, both SQL Server 2008. One
I'm trying to make an experimental web application which minimises redundant data. I have
This the situation: I have one webservice without SSL, which provides two pages for
We have a huge ASP.NET web application which needs to be deployed to LIVE
I have made a web application that administrate questions for a quiz. The web

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.