Solved

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

Posted on 2014-01-01
2
254 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Icons and Colors for Terms 3 24
Need help on C# Linq query on object 6 53
Syntax Error 2 46
Where can I ask about my ASP.NET MVC project? 6 21
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now