Software Engineering
c# design storage settings
Updated Wed, 15 Jun 2022 07:54:03 GMT

Storing persistent settings for each product in list

Sorry if I'm not clear, I didn't touch the program for almost two weeks.

I have a program that reads XML files:

  • A product list
  • Each product's default settings (if custom is not available)
  • Each product's custom settings

Then it constructs a ProductBase object and ProductSettings from either default or custom XML. Afterwards they form a Product object, which is put into a list, and then a WPF DataGrid is filled with list elements.

I'm using very questionable ways to do all this (I'm a beginner) - I realized I should start over because the code is nigh unreadable, and I'm asking here in case I should take a different route while I'm at it. I'm pretty sure current way will make me suffer later on, as even now it causes me headaches.

I need a way to store products list with a possibility to save each product settings (like "is in delivery", or "do not sell" bools) between sessions. It also should take in consideration that product count might change, but it should keep old settings for products that weren't added/removed.

Is there a standard way to do this? It surely must have been done many times. I'm open for any suggestion.

Edit: The product lists aren't huge (probably no more than 100KB), product settings consist of two booleans per product. It would be helpful if it could be portable, but there is no real need for it. I was thinking about a light database, but I couldn't find anything easy to use. Except Sqlite, but I couldn't figure out how to make it work.


I just went with SQLite solution. One table contains dynamic product list, second table contains settings linked to each product. Simple trigger does all the work to link these tables. It's simpler than XML on literally every front. I wish I decided to go this way right at the beginning.