寻找 C# 中最轻松的非 RDBMS 存储方法

发布于 2024-08-27 16:44:51 字数 320 浏览 12 评论 0原文

我正在编写一个完全在客户端运行的简单程序。 (桌面编程?人们还在这样做吗?)我需要一种简单的方法来以结构化形式存储少量数据,但实际上没有必要使用数据库系统。此外,某些数据需要序列化并传递给不同的用户,例如某种“文件”或“文档”。 (以前有人这样做过吗?)

因此,我研究过使用 .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 技术交流群。

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

发布评论

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

评论(4

糖果控 2024-09-03 16:44:51

听起来 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.

明媚殇 2024-09-03 16:44:51

在不了解有关您的应用程序的任何其他信息的情况下,.Net DataSets 可能是您最简单的选择,因为 WriteXmlReadXml 已经存在。

Without knowing anything else about your app, the .Net DataSets would likely be your easiest option because WriteXml and ReadXml already exist.

秋千易 2024-09-03 16:44:51

任何序列化 API 在这里都应该可以正常工作。我会推荐一些基于合同的东西( BinaryFormatter,它是基于类型的),因为这将使其随着时间的推移保持可用(当程序集发生变化时)。

因此,我将构建一个基本对象模型(DTO)并使用以下任何一个:

  • XmlSerializer
  • DataContractSerializer
  • protobuf-net(你们都知道它即将到来......)

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
  • protobuf-net (you all knew it was coming...)

OO, simple, and easy. And easy to use for passing fragments of the data (either between users of to a central server).

如何视而不见 2024-09-03 16:44:51

我会选择嵌入式数据库。使用像 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/).

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