I have a LINQ query where I want to return modified objects. If I were in an immutable Functional mood, I might do something copy-construtor-like, like this:
from widget in widgets select new widget { legs = widget.legs + 1, arms = widget.arms }
Sadly, I'm doing this on a mutable NHibernate entity object and I have to modify the original object. I'm looking for some syntax with a little anonymous method with side-effects, like:
from widget in widgets select { widget.legs += 1; return widget }
(with apologies to Scala syntax)
Now, I can perform this update outside the LINQ query, but I'd rather do it inline, if I can. Is it possible to insert void
operations such as this in LINQ?