Sunday, 8 September 2013

How do I return multiple entities with DbSet.SqlQuery() so that I can take advantage of an entities navigation properties?

How do I return multiple entities with DbSet.SqlQuery() so that I can take
advantage of an entities navigation properties?

I'm currently running Visual Studio 2012, running .NET 4.5 with the Entity
Framework 5 libraries.
I need to run a RAW SQL statement against the database to retrieve some
data through a Full-Text-Search. I'm currently using SqlQuery() found on
my DbSet object.
However, I'd like to populate not only the single Entity from which I'm
running the SQL query against, but also adjoining, child entities so that
I can navigate the children entities through my navigation properties
defined in my models.
I'm able to write the query so the joins are made property, but I'm not
having success in populating the navigation properties. I'm currently not
using the VIRTUAL keyword in my navigation properties so that it hints at
eager loading.
Is there a way to do this with a single query?
Thank you. Phil

No comments:

Post a Comment