在开发和实验期间将对象持久保存在 .net 中的简单/轻量级方法是什么?
我正在寻找一种简单的方法来在试验和创建模拟 UI 或服务时保留对象。我已经知道稍后在生产可发布产品时最终将使用什么 ORM,但我不想在这个阶段费心将其全部设置好。
我正在寻找这样的东西:
- 安装要求低(理想情况下,单个 dll)
- 设置要求低(没有列定义,没有 XML 映射,没有表创建..)
- 性能低(实际上只需要支持 1 或 2 个并发)用户)
- 在应用程序重新启动时保留数据
我真正想要的是类似哈希表的东西,可以在应用程序重新启动后继续存在。
您认为哪些工具适合此目的?当您想要保持简单的数据结构而不出现任何混乱时,您会采取什么方法?
I'm looking for a simple way to persist objects when experimenting and creating mock UIs or services. I already know what ORM I'll ultimately use later on when producing a releasable product but I don't want to bother setting it all up at this stage.
I'm looking for something that:
- has low install requirements (ideally, single dll)
- has low setup requirements (no column definitions, no XML mappings, no table creation..)
- has low performance (really just needs to support 1 or 2 concurrent users)
- persists data across application restarts
What I really want, is something like a hashtable that survives application restarts.
What tools would you see appropriate for this? What approaches do you take when you want to persist simple data structures without any muss?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以只使用框架的内置 序列化支持。
就您的要求而言:
You could just use the framework's built-in Serialization Support.
In terms of your requirements:
勾选所有这些框将很困难。
我过去使用过 SQLite,非常适合模拟数据库。
至于持久性,您可以尝试使用本机 Xml 序列化/JSON 或 Google 的 ProtoBuffers。
如果您有数据的域模型,那就更好了,这样您就可以轻松地从底层数据中进行反序列化/恢复(在简单的转储文件/xml/db 中)。
这样,您将始终使用域模型而不是底层数据。您可以稍后更改底层数据,但域模型保持不变
well will tricky to tick all these boxes.
I have used SQLite in the past, was quite to mock DBs.
As it comes to persistance, you can try to use native Xml Serialization/JSON or Google's ProtoBuffers.
It is better if you have your Domain Model for your data, that way you can easily Desereliaze/Restore from underlying data (be in simple dump file/xml/db).
that way you will alwyas work with Domain Model and not the underlying data. you can change your underlaying data later on but your Domain Model stays the same