简体   繁体   English

如何存储我的数据(C#.net)

[英]How to store my data (C#.net)

I'm having a bit of a problem deciding how to store some data. 我在决定如何存储一些数据时遇到了一些问题。 To see it from a simple perspective, it will be a simple table of data but there will be many tables. 从简单的角度来看,它是一个简单的数据表,但会有很多表。 There will be about 7 columns in each table, but again there will be a lot of tables (and they will be created at runtime, whenever the customer wants a clean grid) 每个表中大约有7列,但同样会有很多表(只要客户想要一个干净的网格,它们就会在运行时创建)

The data has to be stored locally in a file (and there will not be multiple instances of the software running). 数据必须存储在本地文件中(并且不会有多个正在运行的软件实例)。

I'm using C# 4.0 and I have been looking at using XML files(one file per table, or storing multiple tables in a file), sqlite, sql server CE, access etc. I will be happy if someone here has some comments or suggestions on how to do/not to do. 我正在使用C#4.0,并且一直在使用XML文件(每个表一个文件,或在一个文件中存储多个表),sqlite,sql server CE,访问权限等。如果有人在这里发表评论或关于如何做/不做的建议。 Stability and reliability(eg no trashed databases because of unstable third party software) is probably my biggest concern. 稳定性和可靠性(例如,由于第三方软件不稳定而不会破坏数据库)可能是我最大的担忧。

If you are looking to store the data locally in a file, I would recommend the sqlite option since it seems your data is created in the form of a database table already. 如果您希望将数据本地存储在文件中,则建议使用sqlite选项,因为似乎您的数据已经以数据库表的形式创建。 Sqlite is already built to handle multiple tables and columns so it means less mental overhead for you, the developer. Sqlite已经构建为可以处理多个表和列,因此对于您(开发人员)而言,这意味着较少的精神开销。

http://web.archive.org/web/20100208133236/http://www.mikeduncan.com/sqlite-on-dotnet-in-3-mins/ is a decent tutorial to give a quick overview on how to set it up and get going. http://web.archive.org/web/20100208133236/http://www.mikeduncan.com/sqlite-on-dotnet-in-3-mins/是一个不错的教程,可以快速概述如何进行设置起身去。

As for what NOT to do: don't try to make your own scheme to save the data to a file, it's a well understood problem that has been solved many times over, why re-invent the wheel? 至于不该做的事情:不要尝试制定自己的方案将数据保存到文件中,这是一个众所周知的问题,已经解决了很多遍了,为什么要重新发明轮子呢?

XML wont be a good choice if you are planning to make several queries, since loading text files may be painful when they grow (talking about files over 1mb). 如果您打算进行多个查询,XML将不是一个很好的选择,因为加载文本文件可能会很麻烦(谈论超过1mb的文件)。 If you plan to mantain the data low, the xml would be good to keep it simple. 如果您打算将数据保持在较低水平,那么将xml保持简单就可以了。 I still won't use it, but if you have a background, then the benefits will be heavier than the learning curve. 我仍然不会使用它,但是如果您有背景,那么收益将比学习曲线重。

If you have no expertise in any of them, and the data is light my suggestion is SQLite, I beleive is the best lightweight DB for .Net and the prvider is very good. 如果您在任何方面都没有专门知识,并且数据比较轻,我建议使用SQLite,那么我相信,.NET最好的轻量级数据库,并且prvider很好。 you can find it easily on Google. 您可以在Google上轻松找到它。

I would tell you that Access is not recommendable, but this is a personal oppinion. 我会告诉您,不建议使用Access,但这是个人的看法。 Many people use it and I think is for some reason. 很多人使用它,我认为是出于某种原因。 So you should check it out and try it. 因此,您应该检查一下并尝试一下。

Again, my final recommendation is SQLite, unless you know very well another one, in which case you'll have to think how much your data is going to grow. 同样,我的最终建议是SQLite,除非您非常了解另一项,在这种情况下,您将不得不考虑数据将增长多少。 If you plan to have a DB around 100mb, any of them, except xml would do; 如果您打算在100mb左右有一个数据库,那么除xml之外的任何一个都可以。 If you think it'll grow bigger than that, consider SQLite heavily 如果您认为它会变得更大,请考虑使用SQLite

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM