如何获得报告的枚举值

时间:2023-01-26 14:29:15

Designation{Admin=1,Manager=2} Database contains just the digit 1,2.

名称{Admin = 1,Manager = 2}数据库仅包含数字1,2。

Now i want to built RDLC Report but the report doesn't show the digit. The report must show the digit across value (for example, 1 for Admin)

现在我想建立RDLC报告,但报告没有显示数字。报告必须显示值的数字(例如,1表示管理员)

How can I do that?

我怎样才能做到这一点?

2 个解决方案

#1


Are you using C#?

你在用C#吗?

If so, you want to use Enum.GetNames()
See this link for a code example.

如果是这样,您想使用Enum.GetNames()请参阅此链接以获取代码示例。

If you need to do it in SQL code, then I agree with simply having a lookup table (although it can be a pain to keep the code enum and DB in sync).

如果您需要在SQL代码中执行此操作,那么我同意简单地使用查找表(尽管保持代码枚举和DB同步可能会很麻烦)。

#2


Create a table that holds the numeric values and the corresponding text values. Then create a User Defined Function to return the text value based on the enumerated value you return in the query for the report. The user defined function can be called in the select statement and will return the text value.

创建一个包含数值和相应文本值的表。然后创建用户定义函数,以根据您在报表查询中返回的枚举值返回文本值。可以在select语句中调用用户定义的函数,并返回文本值。

#1


Are you using C#?

你在用C#吗?

If so, you want to use Enum.GetNames()
See this link for a code example.

如果是这样,您想使用Enum.GetNames()请参阅此链接以获取代码示例。

If you need to do it in SQL code, then I agree with simply having a lookup table (although it can be a pain to keep the code enum and DB in sync).

如果您需要在SQL代码中执行此操作,那么我同意简单地使用查找表(尽管保持代码枚举和DB同步可能会很麻烦)。

#2


Create a table that holds the numeric values and the corresponding text values. Then create a User Defined Function to return the text value based on the enumerated value you return in the query for the report. The user defined function can be called in the select statement and will return the text value.

创建一个包含数值和相应文本值的表。然后创建用户定义函数,以根据您在报表查询中返回的枚举值返回文本值。可以在select语句中调用用户定义的函数,并返回文本值。