Query a DataSet(查询数据集)
问题描述
我正在将 XML 文件中的数据读入强类型 DataSet
.数据最终出现在多个表中;我可以对其运行查询以创建非规范化视图以显示在 DataGrid
中吗?
I'm reading data from XML files into a strong typed DataSet
. The data ends up in multiple tables; can I run queries against it to create a denormalized view to display in a DataGrid
?
示例输入:
<PeopleFile>
<address>
<street>123 Some Street</street>
<town>Anytown</town>
<resident>
<first>Jane</first>
<last>Doe</last>
</resident>
<resident>
<first>John</first>
<last>Doe</last>
</resident>
</address>
<address>
<street>456 Tree Street</street>
<town>Westwood</town>
<resident>
<first>Mary</first>
<last>Jones-Smith</last>
</resident>
<resident>
<first>Mike</first>
<last>Smith</last>
</resident>
<resident>
<first>Kate</first>
<last>Smith</last>
</resident>
</address>
</PeopleFile>
期望的输出:
123 Some Street Anytown Jane Doe
123 Some Street Anytown John Doe
456 Tree Street Westwood Mary Jones-Smith
456 Tree Street Westwood Mike Smith
456 Tree Street Westwood Kate Smith
我应该补充一点,除了每个文件有多个表之外,我的真实数据也被拆分到多个文件中,AFAIK 需要将这些文件加载到单独的 DataSets
中.
I should add that in addition to multiple tables per file, my real data is also split among multiple files which AFAIK will require being loaded into separate DataSets
.
推荐答案
是的,使用 Linq.有一组特殊的扩展称为 Linq-to-Datasets.
Yes, use Linq. There is a special set of extensions called Linq-to-Datasets.
您显然需要 .NET 3.5,并添加 using System.Data;
You will need .NET 3.5 obviously, and add using System.Data;
如果您的多个文件遵循相同的架构,您应该能够将它们读入 TypedDataSet 的单独实例并 Merge()
这些实例.
If your multiple files follow the same schema you should be able to read them into separate instances of the TypedDataSet and Merge()
those instances.
这篇关于查询数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:查询数据集


基础教程推荐
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- rabbitmq 的 REST API 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01