C# Load()将枚举转换为整数

C# Load()将枚举转换为整数,c#,sqlbulkcopy,fastmember,C#,Sqlbulkcopy,Fastmember,我正在使用SqlBulkCopy向表中插入一些数据。我的数据对象具有枚举属性。我想将其保存为值(G),而不是int(1) 在调用dataTable.Load()时,属性从“G”变为1。显然这就是发生的事情吗? 有办法吗?我最初认为可能是FastMember(Marc Gravell)在ObjectReader上的问题,但是reader仍然有“G”的值,所以问题出在DataTable或Load() 如何将枚举保存为字符串而不是int private static DataTable To

我正在使用
SqlBulkCopy
向表中插入一些数据。我的数据对象具有枚举属性。我想将其保存为值(G),而不是int(1)

在调用
dataTable.Load()
时,属性从“G”变为1。显然这就是发生的事情吗?

有办法吗?我最初认为可能是FastMember(Marc Gravell)在
ObjectReader
上的问题,但是
reader
仍然有“G”的值,所以问题出在
DataTable
Load()

如何将枚举保存为字符串而不是int

    private static DataTable ToDataTable<T>(IEnumerable<T> data, List<string> columnNames)
    {
        string assemblyQualifiedName = typeof(AccrualHistory).AssemblyQualifiedName;
        Type accrualHistoryType = Type.GetType(assemblyQualifiedName);
        List<string> memberInfos = accrualHistoryType.GetMembers().Select(x => x.Name).ToList();

        // Only include properties that are *also* columns in the table.
        IEnumerable<string> propertiesThatAlsoExistInTable =
            memberInfos.Intersect(columnNames, StringComparer.OrdinalIgnoreCase);

        var dataTable = new DataTable();
        using (var reader = new ObjectReader(typeof(T), data, propertiesThatAlsoExistInTable.ToArray()))
        {
            // This is where the enum goes from 'G' to 1.
            dataTable.Load(reader); 
        }

        return dataTable;
    }
下面是我试图保存的对象的属性:

public FrequencyType FrequencyType { get; set; }

这是一次性加载吗?不是。这是一个每晚运行的进程,在该进程中会发生多个SQL大容量复制操作。我的建议是在之后运行UPDATE TABLE语句,将数值字段转换为所需字符串,并用该字符串填充另一列。有趣。我可以加上这个选项。这意味着该列不能是查找表的FK。在返回数据表之前,能否在内存中进行更新?这样地:
public FrequencyType FrequencyType { get; set; }