为什么返回的DataTable在FileHelpers中具有只读列 [英] Why does the returned DataTable has readonly columns in FileHelpers
问题描述
我想知道为什么 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.
有没有一种方法可以告诉Filehelpers不要这样做?因此,我不必浪费时间再次进行所有操作吗?
Is there a way I can tell Filehelpers to not do this? So I don't have to waste time going through all of it again?
推荐答案
FileHelpers类 RecordOperations.CreateEmptyDataTable()
方法对此负责,它不是虚拟的.
The FileHelpers class RecordOperations.CreateEmptyDataTable()
method is responsible for this and it is not virtual.
我认为原因可能与通过 DataTable.Load(IReader)
使用普通的 DataReader
类似,这也会创建只读行.
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.
但是,很容易通过遍历列而不是行来解决:
However, it is easy to fix by going through the columns instead of the rows:
foreach (DataColumn col in dt.Columns)
col.ReadOnly = false;
这篇关于为什么返回的DataTable在FileHelpers中具有只读列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!