views:

199

answers:

1

I have a data structure defined as:
Dictionary<Guid, List<string>> _map = new Dictionary<Guid, List<string>>();

I'm trying to create a lambda expression that given a string, returns a IEnumerable of Guids associated with any List<string> containing that string.

Is this reasonable/possible or should I use a more appropriate data structure?

Thanks in advance!
Kim

+3  A: 

Try the following

Func<string,IEnumerable<Guid>> lambda = filter => (
   _map
      .Where(x => x.Value.Contains(filter))
      .Select(x => x.Key));

Usage

var keys1 = filter("foo");
var keys2 = filter("bar");
JaredPar
That's it! Just a small change in usage to:var keys1 = lambda("foo")Saved me a ton of time - thanks!