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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:48:00+00:00 2026-06-15T12:48:00+00:00

struggling To achieve a solution for a basic Task: working with more than one

  • 0

struggling To achieve a solution for a basic Task:

working with more than one Sql Data table, as a source, for a WebSite application…

that’s what leads me here once again… seeking for an Experienced C# .net Developers Help.

i was just trying to add some basic logic for a proper implementation,Like using

a dedicated namespace & classes, To Hold reference for All DATABASE tables,

(before i try working / learning about Entities Framework approach.)

i would like to try implement same of basic features of EF …by my self, and that way… i will also learn how to properly work with classes.

as it is so far … structured : with my little knowledge

a ‘helper‘.. namespace , say the company name is: HT technologies

so I’ve named the namespace HT_DbSchema …that contains :

  • tables names
  public sealed class HTDB_Tables
  {
    public const string Customers= "Customers";
    public const string Times= "Times";
  }
  • tables IDs
 public sealed class HT_tblIDs
 {
    public const int tblCustomersID = 1, tblTimesID = 2;
 }
  • tables Columns Lists …(just one example)
public class HTDB_Cols
{

      public class tblCustomers
      {
           public const string CustId  = "custId",
                               CustName  = "custName",
                               CellPhone  = "cellPhone" .... etc'
      }
}

and as all those 3 classes are serving all projects ..

there’s another helper class for constructor Per Table For the Current Project

public class DBMetaDetails
{
       public struct DbTable
       {

             public string TableName { get; set; }
             public int TableID { get; set; }
       }
}

so still these are all construction / helpers Classes and are separated from the project,

now for current project

What is The Appropriate way to get it done, using above Classes and constructor within a project
(i could name those templates)

what i was doing so far to implement some order is :

protected void Page_Load(object sender, EventArgs e)
{
    if(!Page.IsPostBack)
    {
      .... some other App inits here
    }

    else
    {

    }    

    // this method should be the one that instanciates the DbTable struct
   //and set the values of tables name and "ID"
   setTablesReferences(); 
}

And Here’s where the confusion starts :

in a day by day usage i want to try implement it in a WebSite application :

public void setTableReferences()
{
    DBMetaDetails.DbTable CustMeta = new DBMetaDetails.DbTable();
    DBMetaDetails.DbTable TimesMeta = new DBMetaDetails.DbTable();

}

so now i need to set CustMeta & TimesMeta details(ids & names)

the struct has a kind of a template structure a kind’a systematic technique to initialize and assign values, so it brings some decent order to my logic with it’s existence .

so what is the confusing part ?

from one point of view(safety), i need those tables detailes to be readonly

so DbTable.TableID, and DbTable.TableName would not get overWriten by mistake.

having said that, there should be only one place it could be SET … a dedicated section of the application, like setTableReferences() above,… there i might add :

CustMeta.TableID = HT_tblIDs.tblCustomersID
CustMeta.TableName = HTDB_Tables.Customers;

on the other hand, i need the information of the tables to be Accessible,

so if let’s say i would like to add those DataTables into a DataSet

DataSet ALLTablesSet = new DataSet();

// assuming the SQL actions already been taken in another method previosly...
// so DataTable is already retrived from DB 
//...but only as a short usage example:

AllTablesSet.Tables.Add(new DataTable(CustMeta.TableName));

My Question is What is the Correct Way to work with structs … as in My Scenario,

So in one section of app: you would initialize – assign it with a value privately.

and from other sections of the app you could use its value (Only For Readings)

so that way, the application will not be able to access it’s value for writing,
only by reading values, i think it should be trough another (Public ReadOnly) Variable.

so that variable was meant to be exposed …and it’s value could not be “harmed”

  • 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-15T12:48:02+00:00Added an answer on June 15, 2026 at 12:48 pm

    If I understand the question correctly, the way I would prevent other code from modifying it is by removing the setters on the properties. However, you still need to set them at some point, so rather than removing the setters completely, you can just make them private. For example:

    public string TableName { get; private set; }
    

    If you do this, the only place you can set this data is within the struct itself, so you would need to create a constructor that took the initial values you wanted. So something like:

    public struct DbTable
    {
        public DbTable(string tableName, int tableId)
        {
            this.TableName = tableName;
            this.TableID = tableId;
        }
    
        public string TableName { get; private set; }
        public int TableID { get; private set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been struggling to find a solution to achieve this. I have an HTML
I'm struggling to achieve folowing without temp. files. #!/bin/bash tar ztf $1 | sort
Im struggling with this one. I have a list of items and on a
While I'm still struggling to find a solution for this question, i have another
Hi all I am struggling to achieve my my goal and I really need
Hi i'm struggling to write a particular MySQL Join Query. I have a table
I am struggling to collect data from a nested list. The list looks something
I'm struggling to figure out how to achieve this count. Models are User, Test,
I'm really struggling with this piece of code. What I'm trying to achieve: I
I'm struggling to make this script work. What I'm looking to achieve is to

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.