Just wanted to check to see if there's a more elegant way to accomplish this task using Linq. I'm greatly simplifying the code for brevity. I'll go into my reasons in a minute, but it goes like this:
(from t in doc.Descendants(p + "Task")
where t.Element(p + "Name") != null
select new {
FirstName = t.FirstName,
LastName = t.LastName,
FullName = FirstName + " " + LastName // Error!
}
Yes, I know it would be simple to do FullName = t.FirstName + " " + t.LastName, but let's imagine for a second that FirstName and LastName were big ugly inline calculations and not simple variables. So FullName = [big ugly calc 1] + [big ugly calc 2]. So in the spirit of DRY, is there a better way this could be done? My first thought is to write a function that gives me FirstName and LastName. But is there something better?