I was working on some LINQ queries for an application, but ran into an issue where my output column needed to be a different name, other than the column name that was returned.
It was rather easy but i figured I would throw it up here for future use, or for those people who haven’t run into this yet.
Here is an original query that will return some strings but with the default column name (in this case it is “word”)
from word in "one two three four five".Split()
select new
{
word
}
Here is the update LINQ expression that renames the default column to “TheWord”
from word in "one two three four five".Split()
select new
{
TheWord = word
}