I just want to check if there is a more elegant way to accomplish this task with Linq. I greatly simplify the code for brevity. I will review my reasons in a minute, but this happens as follows:
(from t in doc.Descendants(p + "Task")
where t.Element(p + "Name") != null
select new {
FirstName = t.FirstName,
LastName = t.LastName,
FullName = FirstName + " " + LastName
}
Yes, I know that it would be easy to make FullName = t.FirstName + "" + t.LastName, but imagine for a second that FirstName and LastName were big ugly built-in calculations, not just variables. So FullName = [big ugly calc 1] + [big ugly calc 2]. So, in the spirit of DRY, is there a better way to do this? My first thought is to write a function that gives me FirstName and LastName. But is there something better?
billb source
share