i am stuck with a simple variable assignment , the only condintion to make it littl complex for me is that i need the struct values to be private , so they wont be modified alswhwere
and to be able to use values of the struct but in a safe way, i am trying to use public readonly
variables . so that's how i can share information with the application in read only mode , shouldn't it be simple ?
what am i missing ?
as the application starts in Page_Load
i am calling SetTablesMetaDetails()
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
//..thus sets the values of tables "Name" and "ID"
currProjData.setTablesReferences();
}
- The
struct
, will be used to assign values :
public class DBMetaDetails
{
public struct DbTable
{
public DbTable(string tableName, int tableId): this()
{
this.TableName = tableName;
this.TableID = tableId;
}
public string TableName { get; set; }
public int TableID { get; set; }
}
}
- The current project class to hold values
public static class currProjData
{
static DBMetaDetails.DbTable CustomersMeta = new DBMetaDetails.DbTable();
static DBMetaDetails.DbTable TimesMeta = new DBMetaDetails.DbTable();
public static void SetTablesMetaDetails()
{
TimesMeta.TableID = HTtIDs.TblTimes;
TimesMeta.TableName = HTDB_Tables.TblTimes;
CustomersMeta.TableID = HTtIDs.TblCustomers;
CustomersMeta.TableName = HTDB_Tables.TblTimeCPAReport;
}
public static readonly int CustomersTid = CustomersMeta.TableID;
public static readonly string CustomersTblName = CustomersMeta.TableName;
public static readonly int TimesTid = TimesMeta.TableID;
public static readonly string TimesTblName = TimesMeta.TableName;
}
My Problem is that i need those two sets of tables (Tid
& TblName
) details to be exposed to rest of application but as application starts it calls the SetTablesMetaDetails()
and the four last lines does not execute , i've tried moving this section into SetTablesMetaDetails()
but it's not the correct syntax , i am geting errors ,
What is the correct way to acomplish assignment of CustomersTid
? (offcorse rest of the 3 as well)
public static readonly int CustomersTid = CustomersMeta.TableID;
this is what i am missing cause i don't know how to get it initialized in same way the struct above does ... preferebly in one method call