Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
have two tables, where I've abstracted the SQL column names. The first table has an "original" column name and a "header" name. The second table uses the "original" column name.

--Columns table
ColumnName HeaderName
StandardColumn_1 balance
StandardColumn_2 FName
StandardColumn_3 LName
StandardColumn_4 Age

--Records table
StandardColumn_1 StandardColumn_2 StandardColumn_3
Value1 Value2 Value3
Now, I have to write a query using the "header" name in C#. How can I query the records table using the "header" name?

e.g. string balance = "StandardColumn_1";, but I need to get the values dynamically from the columns table.
Posted

Use aliases - Aliases[^]
 
Share this answer
 
You should create a PIVOT for this.

My article explains[^] it all.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900