gpt4 book ai didi

c# - 如何在 MS SQL Server 2014 中创建新的数据类型?

转载 作者:行者123 更新时间:2023-11-30 18:21:10 26 4
gpt4 key购买 nike

在我的应用程序的服务器端,我使用 MS SQL Server 2014 Express。在客户端,我有 C# WPF 应用程序,那里有以下枚举类型:

/// <summary>
/// User authorization level.
/// </summary>
public enum UserAuthorizationLevel
{
/// <summary>
/// Only visual inspection is allowed (the first lower level).
/// </summary>
Inspection,
/// <summary>
/// Some settings in apparatus are allowed (the second level).
/// </summary>
SettingDeviceParametersApplied,
/// <summary>
/// Some more setting in apparatus are allowed than in the second level (the third level).
/// </summary>
Maintenance,
/// <summary>
/// Apparatus manufacturer level - full access is allowed (the highest level).
/// </summary>
Manufacturer
}

我能否在服务器端(在 MS SQL Server 数据库中)创建此类型并将此类型用作数据库表中字段的类型?

最佳答案

我建议你看看这个:Best method to store Enum in Database

您拥有的是枚举,而不是类型。 Enum 转换为 Int 类型。所以你会得到这样的东西:

/// <summary>
/// User authorization level.
/// </summary>
public enum UserAuthorizationLevel
{
/// <summary>
/// Only visual inspection is allowed (the first lower level).
/// </summary>
Inspection = 0,
/// <summary>
/// Some settings in apparatus are allowed (the second level).
/// </summary>
SettingDeviceParametersApplied = 1,
/// <summary>
/// Some more setting in apparatus are allowed than in the second level (the third level).
/// </summary>
Maintenance = 2,
/// <summary>
/// Apparatus manufacturer level - full access is allowed (the highest level).
/// </summary>
Manufacturer = 3
}

关于c# - 如何在 MS SQL Server 2014 中创建新的数据类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35893321/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com