我有一个枚举如下:
[Flags]
public enum AggregationLevel
{
/// <summary>
/// 00000001
/// </summary>
Department = 1,
/// <summary>
/// 00000010
/// </summary>
Gbu = 2,
/// <summary>
/// 00000100
/// </summary>
Division = 4,
/// <summary>
/// 00001000
/// </summary>
Region = 8,
/// <summary>
/// 00010000
/// </summary>
Market = 16,
/// <summary>
/// 00100000
/// </summary>
Cluster = 32,
/// <summary>
/// 01000000
/// </summary>
Store = 64
}
然后我有一个存储过程参数,它需要一个 varbinary(字节数组)。
我有一个应该传递给它的枚举实例:
AggregationLevel thisLevel = AggregationLevel.Department & AggregationLevel.Division;
然后,该值应传递给此存储过程:
var parameter = new SqlParameter("@pBitMask", SqlDbType.VarBinary)
参数 = ?
如何将我的“thisLevel”枚举转换为字节数组,以便可以将其分配给这个 sql 参数?
谢谢,