Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming you go for speed an low on memory consumption, try this:</p> <ol> <li>Create a model class which contains a property for each column in the source table. This is your entity.</li> <li>Read from the source table (if it comes from a database, use a <code>DataReader</code>). Read the data record by record and for each record, create an entity. During reading each field of type string, you can optimize a little bit: <ul> <li>Optimize for speed: read the string and put it directly into the property of the entity.</li> <li>Optimize for memory: read the string, use <code>String.Intern</code> on it and put in into the property.</li> </ul></li> <li>Store all these entities in a collection. Here you have two choises: <ul> <li>Use a <code>List&lt;Entity&gt;</code> to store it all. You can use LINQ on the list and entities to query your collection. This is rather slow on performance but the best solution for memory.</li> <li>If you know in advance which queries/criteria you are going to use, use one dictionay for a set of criteria. For example. If you have the properties "FirstName" and "LastName", make a dictionary which will store your entity as a value and a <code>Tuple&lt;string, string&gt;</code> which the values of the FirstName and LastName. Now it is extremely fast to query on these values. For sorting, use the <code>SortedDictionary</code>. If a key has duplicates, create a dictionary like this: <code>Dictionary&lt;Tuple&lt;string, string&gt;, List&lt;Entity&gt;&gt;</code> which will store all records with the same matching first- and last names. I know this solution requires more coding, but is pretty fast.</li> </ul></li> </ol> <p>Of course you can keep the <code>DataTable</code> solution. If memory is your only concern, try to make a <code>DataReader</code>-wrapper which will <code>Intern</code> all strings. Wrap your wrapper arround the original <code>DataReader</code> and use it to create / fill the <code>DataTable</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload