LINQ, Hashtables and Business Layer

J

Jake McCool

Hello people,

I have a performance query regarding LINQ that I would like some opinions.

Currently we have a business logic framework that is used in n-tier
applications. We read data from a database using a data reader and use this
information to populate a set of business objects.

Our business data is identified by a GUID so we create hashtables for
collections of business objects with the GUID as the key and the business
object itself as the object.

The data manipulation we do uses lots of lookups from these hashtables,
which is simple and really fast because of the hashing. We want to start
using LINQ but we can't find a way of manually piping the data into a
hashtable.

So the question is, is there a way of getting the LINQ data into a hashtable
or is there another way of achieveing the same speed of lookup via LINQ
functionality?

Cheers

JS
 
J

Jon Skeet [C# MVP]

Jake McCool said:
I have a performance query regarding LINQ that I would like some opinions.

Currently we have a business logic framework that is used in n-tier
applications. We read data from a database using a data reader and use this
information to populate a set of business objects.

Our business data is identified by a GUID so we create hashtables for
collections of business objects with the GUID as the key and the business
object itself as the object.

The data manipulation we do uses lots of lookups from these hashtables,
which is simple and really fast because of the hashing. We want to start
using LINQ but we can't find a way of manually piping the data into a
hashtable.

So the question is, is there a way of getting the LINQ data into a hashtable
or is there another way of achieveing the same speed of lookup via LINQ
functionality?

A call to ToDictionary would seem the obvious choice, specifying a
lambda expression which pulls out the GUID as the key.
 
J

Jake McCool

Thanks Jon,

do you know what the performance implications would be by comparison to a
DataReader?
 
J

Jon Skeet [C# MVP]

Jake McCool said:
do you know what the performance implications would be by comparison to a
DataReader?

Unlikely to be significant, particularly if you use compiled queries.
However, the best way to find out is to try it and measure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top