Reputation: 2473
I am using SQLite local database in my C# application (WPF).
Should not you open the database connection once and load all the data in the beginning (instead of opening the connection everytime you need a bit of data from the database)?
My question is where should that data be stored in the application.
Should I create a static class which contains all the information in multi-dimensional arrays or multi-dimensional lists. Or is there a better way to store the information?
Upvotes: 0
Views: 718
Reputation: 376
Yes your initial solution is ok,In order to prevent traffic between your App and DB you should save your data in memory,such as propery that you have mentioned before but you could benefit of Caching advantages.
if your are using .Net framework 4.0 ,you can utilize System.Runtime.Caching ,otherwise, you should be familiar with Enterprise application block 5.0 or lower.
Upvotes: 0
Reputation: 1146
Your question cannot be properly answered without knowing your business logic. However, I can tell you that no most applications do NOT load the entire database into objects but rather queries the data when the data is needed.
For the other part of your question, why dont you create a ADO.Net data model? There are templates available if you are using vs 2010, just type model in the search box after opening new project.
Upvotes: 1
Reputation: 1851
Take a look at datasets and the dataset designer tool of visual studio.
If You use this approach, You can benefit from nice features, like serializing tghe data to xml and so on.,
Upvotes: 0
Reputation: 7197
those are the most common tools for this task:
(by my order of recommendation)
http://en.wikipedia.org/wiki/NHibernate
http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework
http://en.wikipedia.org/wiki/ADO.NET
Upvotes: 1