I would like to generate a select statement similar to a sql select:
public partial class Person{
public string Name {get;set;}
public string FirstName{ get;set;}
public string DisplayName {get;set;}
public string Town{get;set;}
public int Age {get;set;}
}
select p.*, (p.NAME + ', ' + p.FirstName) as DisplayName from Person p
In linq I would do it like this
from p in Person select new
{
p.Name, p.FirstName, p.Age, p.Town, // and so on...
DisplayName = p.NAME + ', ' + p.FirstName
}
Is there a way to do it like in the sql select without listing every property?
Update :
Because I am working with linqToDB here the original class:
[Table("PERSON")]
public class Person{
[Column("ID"), PrimaryKey, NotNull]
public int Id { get; set; }
[Column("NAME")]
public string Name {get;set;}
[Column("FIRST_NAME")]
public string FirstName{ get;set;}
public string DisplayName {get;set;}
[Column("TOWN")]
public string Town{get;set;}
[Column("AGE")]
public int Age {get;set;}
}