Stephen K
Stephen K

Reputation: 737

Best way to store infrequently changing information to use in applications?

I have a list of store information.

Each store has a region, a zone, and a store number.

The way I've been doing this now is:

I have a Store class, and a List with elements type Store.

In each application, I have to add this long list of StoreList.Add(new Store() { ... }), which looks bad, is sloppy, and totally not convenient. So I was looking for a way to use this information across multiple solutions/projects.

I don't want to use a database because I don't really want additional overhead in what could be simple scripts. Is a DLL something I would use in this circumstance?

Upvotes: 3

Views: 128

Answers (2)

Carlos Grappa
Carlos Grappa

Reputation: 2381

The problem is not whether you want a database or not, but if you need to store your data once your application closes.

Now, you can use a database (could be an embedded one) or a file (xml most probably).

If all your data is stored in code (not the best option really) then yes, you can move that code to a class library project and distribute it wherever you need it.

But still, at the very least this is what i'd do

  • Move your list items to an xml file
  • Create a class that reads this file, and loads it into the list
  • Add the xml file to your project and mark it as an embedded resource (so it'll be packed with the dll)
  • You can read the xml file from the assembly directly (check here on SO how to do it)

Hope that helps

Upvotes: 1

Habib
Habib

Reputation: 223237

You said you don't want to use database, but probably its not a bad choice. You can store the information in a XML file and read that on application startup. Having such information in a class and then dll, would complicate things. If you have to modify a store number, you have to deploy that dll on computers running your application, although modification in XML would be required on computers as well but it would be easier IMO.

Also if you have that information in some central database and loads up that information on application start event, it would provide you a much better option of maintaining your application and having lesser changes in client side / deployment.

Upvotes: 7

Related Questions