tags:

views:

60

answers:

3

Hello Guys.

I have customized collection for indexing reason, its an implement ion of Idicationary (non generic). This is used to hold string based key and object based value.

Now please pardon my ignorance, I have just came out of the cave.

I want use an adapter between, this is a linq adapter which should take linq queries and perform operation on this existing IndexedDictionary.

Why SO ?

This was designed for a .net 2.0 application, now slowly and steadily we are moving toward 4.0 as a part of natural evolution, so we are taking side-by-side aproach so every thing written previously should exist and 4.0 features should be implemented as adapter where ever possible.

I will summarize what I want to cut long story short, I have an existing .net 2.0 IDictionary implementation. Now I would like to use it with LINQ so that can I can take full advantage of expressions. How can I do this ?

A: 

Not sure that I fully understand what your purpose is and what the code needs to do. LINQ is very powerful, you probably don't need an adapter.

For going from LINQ results to Dictionary there is a ToDictionary method in LINQ. See http://www.hookedonlinq.com/ToDictionaryOperator.ashx

Cheers

Chris Farrell

Chris Farrell
+1  A: 

It seems to me that you don't need an adapter. An adapter is for transforming expression trees (IQueryable) to communicate with an underlying data source. For in-memory collections, the existing extension methods such as LINQ to Objects, LINQ to XML and LINQ to DataSets will normally do. If this is not enough, you can write your own extension methods or write instance LINQ methods on your type.

Steven
A: 

You don't need to do anything to the .Net 2.0 Dictionary, just use it like any other LINQ. It implements the IEnumerable<T> interface so it can be used by LINQ. Note that when you iterate through the dictionary using LINQ, the elements will not be in "order" and you will have to use a KeyValuePair<TKey, TValue>.

Callum Rogers
Hey guys, I figured it out my self, all I am required to do is to have a linq provider implemented to access that data source.
Abhishek