Lambdas sound like a type of curry, however the only similarity that these beauties have with Indian food are that they’re hot!

Day by day I’m finding lambdas  more and more useful. I used to only use them when I was querying the entity framework but I’m finding that I’m constantly falling back on them as a concise and simple way to deal with generic collections.

Today I had a problem that I wanted to solve with out the need to generate too much code or create a custom collection.

All I wanted to know was if my products attribute collection had attributes who’s first Item was a provider with the Id of x.

Lambda enabled me to get this information out and loop through it with just a couple of lines of code.

foreach (IDataTransferAttributeItem attributeItem in product.Attributes.Where(a => a.Providers.First().Id == this.providerId))
                  {
                   // TODO: Do something with attributeItem
                  }