Apologies if this has been asked already, but I couldnt find it.
How do I get 'anotherColumnName' in LINQ?
SELECT thisColumnName as anotherColumnName FROM TableName
I have the following which obviously gives me 'thisColumnName' not 'anotherColumnName'
var query = from names in _context.TableName
select names;
return query.ToList();
Solution
@Ian P - thanks to your answer.
For the finished solution I also needed a bit extra as below...
Old version.
public List<OldClassName> GetSomething()
{
var query = from names in _context.OldClassNames
select names;
return query.ToList();
}
New version with column renaming.
public List<NewClassName> GetSomething()
{
var query = from names in _context.OldClassNames
select new NewClassName
{
NewColumName = names.OldColumnName
};
return query.ToList();
}