I have the below dbcontext.cs and the corresponding table.cs which define the DAL in my MVC using entity framework.
The List table in my database does not have a column C but I would like the entity to get the ID,A,B values from DB and get the C from code. Is this possible if so what is the best approach.
The below code fails giving an exception "Invalid Coloumn C".
The other way I can think around is to declare another entity ex:ListEntity2 and add the values after query from ListEnity which I guess is a good way but just wanted to know of any other possibilities.
table.cs:
[Table("List")]
public class ListEntity
{
[Key]
public int ID { get; set; }
public string A { get; set; }
public int B { get; set; }
private string name;
public virtual string C
{
get
{
return name;
}
set
{
name=value ;
}
}
}
dbcontext.cs:
public DbSet<ListEntity> List { get; set; }