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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:38:38+00:00 2026-06-14T07:38:38+00:00

I am working on a database that is maintained by another system, so I

  • 0

I am working on a database that is maintained by another system, so I am unable to make any drastic changes to the tables. The tables in this database have quite a few fields (upwards of 30+) with no two tables having the same naming convention, types, or same number of fields. These tables also change fairly frequently (fields being added, removed or their types being changed) and to make matters worse new tables are created on a frequent basis as well. Now I do have one table that can be strictly typed which is used as a queue.

The problem:

I have to get data from a table given the table name and some columns in that table. The column names are supplied as strings. Since these tables change so often it becomes difficult to maintain strictly typed entities for each table.

How would I design my classes in a way that they are loosely coupled but allow me to work with these tables?

Thanks for the help and sorry if my explanation sucks.

  • 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-14T07:38:39+00:00Added an answer on June 14, 2026 at 7:38 am

    One idea is to use SQL Management Objects (SMO) with Tables to dynamically create strong types.

    Server srv = new Server(conn);
    Database db = srv.Databases["AdventureWorks"];
    
    foreach (Table table in db.Tables)
    {
        Console.WriteLine(" " + table.Name);
        foreach (Column col in table.Columns)
        {
            Console.WriteLine("  " + col.Name + " " + col.DataType.Name);
        }
    }
    

    I’ve written unit test generators for Data Access Layers this way and you could make up Classes using the column DataTypes, eg (look online for a better implementation – in C#):

    Public Function SQLParameterType(ByVal ParameterDataType As String) As String
    
        ParameterDataType = ParameterDataType.ToUpper
    
        If ParameterDataType.IndexOf("NVARCHAR") > 0 Then
            Return "string"
        ElseIf ParameterDataType.IndexOf("VARCHAR") > 0 Then
            Return "string"
        End If
    
        Select Case ParameterDataType
    
            Case Is = "BIGINT"
                Return "Int64"
            Case Is = "INT"
                Return "Int32"
            Case Is = "SMALLINT"
                Return "Int16"
    
            Case Is = "BIT"
                If gIsVBdotNet Then
                    Return "boolean"
                Else
                    Return "bool"
                End If
    
            Case Is = "DATETIME"
                Return "DateTime"
    
            Case Is = "DATETIME2"
                Return "DateTime"
    
            Case Is = "SMALLDATETIME"
                Return "DateTime"
    
            Case Is = "MONEY"
                Return "single" 'float
            Case Is = "FLOAT"
                Return "single" 'float
            Case Is = "REAL"
                Return "double"
                'Case Is = "INT"
                '    Return "int32"
                'Case Is = "INT"
                '    Return "int32"
            Case Else
                Return "666"
        End Select
    
    End Function
    

    With this simple ORM that connects to your database in a schema-neutral way you can loosely couple dynamically generated classes to the dB. The new Dynamic type in .Net 4 seems to be a good polymorphic datatype candidate for this application.

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

Sidebar

Related Questions

I have been working on a database that holds order numbers and order information.
I am working on a MySQL database that is huge (about 120 tables). I
I am working on a database that is expected to operate over multiple distributed
I'm working with a database that has a bunch of serial numbers that are
I am working on a database that is about 6Gb. I need to convert
I am working on a database model that will hold meta data about a
I am working on the design of a database that will be used to
I am working with a legacy database that stores blank values as a single
I'm working with an existing database that has first name and last name seperated
I'm working on a database site now that has the URL structure: example.com/f.php?id=12 I'd

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.