寻找 C# 中最轻松的非 RDBMS 存储方法
我正在编写一个完全在客户端运行的简单程序。 (桌面编程?人们还在这样做吗?)我需要一种简单的方法来以结构化形式存储少量数据,但实际上没有必要使用数据库系统。此外,某些数据需要序列化并传递给不同的用户,例如某种“文件”或“文档”。 (以前有人这样做过吗?)
因此,我研究过使用 .Net 数据集、LINQ、直接 XML 操作,它们看起来都可以完成工作,但在深入研究任何内容之前我想知道如果有一种方法通常被认为比其他方法更容易编码,则可以使用其中的方法。正如我所说,要存储的数据量微不足道,即使一百个人都使用同一台机器,我们谈论的数据也不会超过 10 MB,因此性能并不像可编码性/可维护性那样重要。提前谢谢大家!
I'm writing a simple program that will run entirely client-side. (Desktop programming? do people still do that?) and I need a simple way to store trivial amounts of data in a structured form, but really don't see any need to use a database system. What's more, some of the data needs to be serialized and passed around to different users, like some kind of "file" or perhaps a "document". (has anyone ever done that before?)
So, I've looked at using .Net DataSets, LINQ, direct XML manipulation, and they all seem like they would get the job done, but I would like to know before I dive into any of them if there's one method that is generally regarded as easier to code than others. As I said, the amount of data to be stored is trivial, even if one hundred people all used the same machine we're not talking about more than 10 MB, so performance is not as large a concern as is codeability/maintainability. Thank you all in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
听起来 Linq-to-XML 是一个不错的选择。
链接 1
链接 2
有关于此的大量信息。
Sounds like Linq-to-XML is a good option for this.
Link 1
Link 2
Tons of info out there on this.
在不了解有关您的应用程序的任何其他信息的情况下,.Net DataSets 可能是您最简单的选择,因为 WriteXml 和 ReadXml 已经存在。
Without knowing anything else about your app, the .Net DataSets would likely be your easiest option because WriteXml and ReadXml already exist.
任何序列化 API 在这里都应该可以正常工作。我会推荐一些基于合同的东西(不
BinaryFormatter
,它是基于类型的),因为这将使其随着时间的推移保持可用(当程序集发生变化时)。因此,我将构建一个基本对象模型(DTO)并使用以下任何一个:
XmlSerializer
DataContractSerializer
OO,简单,而且很容易。并且易于用于传递数据片段(在用户之间或到中央服务器之间)。
Any serialization API should do fine here. I would recommend something that is contract based (not
BinaryFormatter
, which is type-based) as that will keep it usable over time (as your assembly changes).So I would build a basic object model (DTO) and use any of:
XmlSerializer
DataContractSerializer
OO, simple, and easy. And easy to use for passing fragments of the data (either between users of to a central server).
我会选择嵌入式数据库。使用像 sqlite 这样的东西对我来说似乎并不算大材小用。您甚至可以尝试它的 C# 端口 (http://code.google.com/p/csharp -sqlite/)。
I would choose an embedded database. Using something like sqlite doesn't seem to be an overkill for me. You may even try its c# port (http://code.google.com/p/csharp-sqlite/).