Reputation:
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
Upvotes: 0
Views: 788
Reputation: 754863
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");
Upvotes: 3