简体   繁体   English

为什么返回的数据表在 FileHelpers 中有只读列

[英]Why does the returned DataTable has readonly columns in FileHelpers

I am wondering why filehelpers return readonly columns.我想知道为什么文件助手返回只读列。

I had a huge problem with them not updating values and could not figure out why.我有一个很大的问题, 他们不更新值,无法弄清楚原因。 Now I have to have another loop to go through all the columns and change them to be not readonly.现在我必须有另一个循环来遍历所有列并将它们更改为非只读。

Is there a way I can tell Filehelpers to not do this?有没有办法告诉 Filehelpers 不要这样做? So I don't have to waste time going through all of it again?所以我不必浪费时间再次经历所有这些?

The FileHelpers class RecordOperations.CreateEmptyDataTable() method is responsible for this and it is not virtual. FileHelpers 类RecordOperations.CreateEmptyDataTable()方法对此负责,它不是虚拟的。

I think the reason might be that it is similar to using a normal DataReader via DataTable.Load(IReader) which would also create readonly rows.我认为原因可能是它类似于通过DataTable.Load(IReader)使用普通DataReader也将创建只读行。

However, it is easy to fix by going through the columns instead of the rows:但是,通过遍历列而不是行来修复很容易:

foreach (DataColumn col in dt.Columns) 
    col.ReadOnly = false;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM