Solved

Pros and Cons of List vs Dictionary for in-memory proxies of DB Tables

Posted on 2014-01-01
2
258 Views
Last Modified: 2014-01-05
I've got an ASP.NET app that currently uses DataSets and TableAdapters, and thus makes heavey use of typed DataRows.

I'm going to convert this to Connected Data Access as described here:

http://msdn.microsoft.com/en-us/data/ff707264.aspx#_Toc261428884

(FYI, I'm not going with anything more abstract, like Entity Framework, in order to maintain migratability)

The example at that link uses Lists as in-memory proxies for the DB tables.

I recently learned that Dictionaries can be searched much faster that Lists, for unique IDs, which I can arrange for have in all the tables I'm using.  Also, Dictionaries can be Typed.

What I'm hoping for is input on the Pros and Cons of List vs Dictionary for these in-memory proxies of DB Tables.

Any help with this would be appreciated.

Thanks!
0
Comment
Question by:codequest
2 Comments
 
LVL 16

Accepted Solution

by:
Stephan earned 500 total points
ID: 39751043
These are a few things that I know about Lists and Dictionaries

Pros dictionary:
Has the smallest memory print
is faster when they have a large set of data

Cons dictionary:
Dictionaries don't have any sort capability

Pros list:
Is faster depending on the field (e.g. string value is faster in lists than dictionaries)
Lists are in a way sorted on insertion

Cons list:
It is getting really slow when the set if data is getting bigger

Big thing between lists and dictionaries is that dictionaries has it's on hash table for the keys. For example, integers are way faster than string values on a hash table.

So I think it really depends on what you want to do with the data.
Most people prefer Lists because there are more flexible because you don't need a key.
But on performance and memory it is recommended to use a Dictionary but it depends what you want to do exactly.

Here is a blog post that takes a quick look at "HashSet vs List vs Dictionary"
http://theburningmonk.com/2011/03/hashset-vs-list-vs-dictionary/
0
 
LVL 2

Author Comment

by:codequest
ID: 39756385
Thanks for input.  Good info.   I'll think on this, see if there are other responses, then close out.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
location of a form 2 25
VB.NET 2008 Winforms Signing 13 33
SSRS Deployment problem 5 67
How to get a Powershell script to launch from Visual Studio 19 22
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question