Nice to have C# 5.0 LinQ feature
currently LinQ only supports projections, instead if we could perform an action for each row inside the linq query itself it would be great.
I had in mind something like the below query in mind. Hopefully C# team would consider this :-)
Collection<DataEndpoint> myObjects = new Collection<DataEndpoint>();
var dataExtensions = from c in dataContext.ETDataExtensions
join d in dataContext.RequestTypeDatas on c.RequestTypeID equals d.RequestTypeID
where d.RequestType == requestType.ToString()
selectOrDo myObjects.Add(c);
Till my next post, adeus.
Regards,
AlD
Comments
- Anonymous
February 15, 2010
This is really cool, I wish if we could have it in C#4 since it is really handy - Anonymous
February 15, 2010
Eric Lippert has already indicated he is opposed to such a feature and it's hard to argue with his reasoning. Although you can cause side effects in LINQ, it's not recommended. By design, functional programming is supposed to be free of side-effects. Therefore adding a feature to LINQ whose sole purpose is to create side-effects would be counter-productive.http://blogs.msdn.com/ericlippert/archive/2009/05/18/foreach-vs-foreach.aspx