I need to run a raw SQL query and return a calculated column. The query matches the properties of a POCO class. The query runs fine when running against the DB but the calculated column is returning null
public class PocoClass
{
public int ID { get; set; }
[NotMapped]
public DateTime? CalculatedDate { get; set; }
}
Query fake code (actual query more complex):
string sql = @"SELECT ID, max(date) as CalculatedDate
from randomtable
where ID = 1
group by ID
order by CalculatedDate";
var result = db.Database.SqlQuery<PocoClass>(sql).ToList();
I thought using the "as CalcluatedDate " would allow the result to include that field but its not working.
What am I missing?