XML 文件持久性的 LINQ to SQL 等效项

发布于 2024-08-14 22:32:45 字数 266 浏览 1 评论 0原文

Microsoft 通过 LINQ to SQL 映射使保存对象变得非常容易。

然而,有时我想要更轻量级的东西,即能够在应用程序关闭时将对象保存到文件中,然后再次读回它们。 XML 看起来像是一种自然的数据格式,而不是发明一种新的数据格式。 (当然,有人可能会说 XML 是新的 ascii,并且我们仍然存在定义数据模式等问题......)。

是否有预定义的方法来执行此操作,或者我是否必须手动找出 XML 数据格式并编写例程来读/写它们,即通过构造 DOM 等效项然后另存为 XML?

Microsoft has made saving objects very easy with their LINQ to SQL mapping.

However, I would sometimes like something a little more lightweight, i.e. the ability to save objects to a file when an application closes, and read them back in again. XML seems like a natural data format rather than inventing a new data format. (Of course, one could argue that XML is the new ascii, and we still have the problem of defining the data schema etc. ..).

Is there a predefined method of doing this, or am I going to have to manually figure out an XML data format and write routines to read/write them, i.e. by constructing a DOM equivalent and then saving as XML?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相对绾红妆 2024-08-21 22:32:45

如何处理 数据集 和 < a href="http://msdn.microsoft.com/en-us/library/system.data.datatable.aspx" rel="nofollow noreferrer">DataTables 等 - 然后 将它们序列化为 XML

How about working with your data in DataSets and DataTables, etc - then serializing them as XML?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文