P
P
p4p2016-11-20 20:48:39
C++ / C#
p4p, 2016-11-20 20:48:39

Storing data in C#, what's the best way?

Need to get data by id, how to store them in c#? DB is expensive to use, since there is little data.
There is let's say id 5 and 4 values. What will help here? Dictionaries? Lists? I didn't work, can't find a solution. How to search in dictionaries and store several values ​​under one key?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rou1997, 2016-11-20
@Rou1997

Dictionaries and lists for storage in RAM, but you still need to write them to disk somehow, if the database is not suitable, then serialization to JSON or XML.
Under the key, store an array or list, and there are already values ​​\u200b\u200bin it, by the way, the JSON and XML formats all support this.

D
Dmitry Makarov, 2016-11-21
@DmitryITWorksMakarov

There is such class Lookup . Allows you to map multiple values ​​to the same key.
You can get an object of this type from any IEnumerable<TElement> using several overloaded ToLookup(...) methods.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question