SQL中用于C#的自定义列名 [英] Customized Column Names in SQL for C#

查看:139
本文介绍了SQL中用于C#的自定义列名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有两个表,我已经抽象了SQL列名。第一个表有一个原始列名和一个标题名称。第二个表使用原始列名。



- 列表

ColumnName HeaderName

StandardColumn_1余额

StandardColumn_2 FName

StandardColumn_3 LName

StandardColumn_4年龄



- 记录表

StandardColumn_1 StandardColumn_2 StandardColumn_3

Value1 Value2 Value3

现在,我必须使用C#中的标题名称编写查询。如何使用标题名称查询记录表?



例如string balance =StandardColumn_1;,但是我需要从列表中动态获取值。

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.

推荐答案

使用别名 - Aliases [ ^ ]
Use aliases - Aliases[^]


你应该为此创建一个PIVOT。



我的文章解释 [ ^ ] all。
You should create a PIVOT for this.

My article explains[^] it all.


这篇关于SQL中用于C#的自定义列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆