I am trying to query something like this:
var values = new Entities().result.SqlQuery(
"select distinct
i.item_type_id,
Min(value) over (partition by i.item_type_id) as min,
Max(value) over (partition by i.item_type_id) as max,
Avg(value) over (partition by i.item_type_id) as avg
from items i
inner join packages p on p.id = i.package_id "
WHERE ... ").ToList();
First I tried var values = new Entities().item.SqlQuery(...)
but the result has nothing to do with item, item has different properties from the result of this query.
Than I created result object:
public partial class rolling_table
{
public int item_type_id { get; set; }
public int min { get; set; }
public int max { get; set; }
public int avg { get; set; }
}
and run var values = new Entities().result.SqlQuery()
But it is complaining that
The entity type result is not part of the model for the current context.
I guess it thinks result is a table in the database, however it is not.
How can I query custom type, not persistent objects ?
thanks