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();
Use an anonymous type:
var query = (from name in _context.Table
select new { anotherColumnName = name.ColumnName });
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With