迭代强类型数据集
我基本上需要能够迭代表以提取、转换数据并将其加载到类型化数据集中。根据列表中的表名称,我需要构造 TableNameTableAdapter.GetData(),然后构造 TableNameTableAdapter.Update()。我唯一能想到的(除了为每个表编写此代码之外)是使用反射,但希望其他人有建议。
非常感谢...
I basically need to be able to iterate through tables to extract, transform and load data into typed datasets. Based on the table name from a list I need to construct the TableNameTableAdapter.GetData() and then TableNameTableAdapter.Update(). The only thing I can think of (beside writing this code for each table) is using reflection, but hoping somebody else has a suggestion.
Much appreciated...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
无论如何,您都必须使用反射,因为调用正确的 TableAdapter 将需要使用反射加载类,以便您可以使用反射调用 GetData 方法。
这一切都违背了 TypedDataSets 的目的。是否存在不适合案例陈述的原因?您也没有向我们提供关于您想要枚举的实际数据是什么样子的良好线索,因此甚至很难给出如何枚举数据并通过反射调用的答案。
You are going to have to use reflection no matter what because invoking the correct TableAdapter is going to require loading the class with reflection so you can invoke the GetData method with reflection.
This all kind of defeats the purpose of TypedDataSets. Is there a reason where a case statement would not be appropriate? You also haven't given us a good clue as to what the actual data you want to enumerate looks like so it's hard to even give an answer on how to enumerate the data and invoke with reflection.
您还可以访问类型化数据集下的非类型化数据集。但不确定这在这种情况下是否对您有帮助。
You can also access the untyped dataset underneath the typed one. Not sure if this helps you or not in this situation though.