I am trying to figure out how to make my DbSet
initialization come from a custom query.
Explanations:
My DbSet will be read-only.
Lets say I have 3 tables in my Database. I wrote an SQL query that makes complex selection on the 3 tables. Now I want to use Entity Framework to query on the results of the query.
I think this is possible by creating a thing like this :
class MyCustomContext : DbContext
{
public MyCustomContext(string connectionString)
: base(connectionString)
{
}
public DbSet<MyQueryResultRow> ResultsRows { get; set; }
}
But I don't know how to say to the DbContext "Hey, for retrieving the rows of that DbSet, use that sql query!".
NB : I can't and I don't want to modify the database (I can't create a sql view for example).
Any idea?