EF SqlQuery with navigation properties

c# entity-framework entity-framework-6 navigation-properties sql-server

Question

I want call sp in t-sql from EF 6. At the same time i want load data to navigation property. On sql server side my SP Joins 2 table and returns. But EF side dont bind navigation properties.

My query code loads car data but when i want reach Engine.Name it comes null. How can i fill it ?

//query code
_context.Cars.SqlQuery("select * from Car join Engine on Cars.EngineID = Engine.EngineID")

//sample code
public class Car
{
    public int ID { get; set; }
    public string Name { get; set; }
    public int EngineID { get; set; }
    public virtual Engine CarEngine { get; set; }
}

public class Engine
{
    public int EngineID { get; set; }
    public string Name { get; set; }
}
1
1
1/14/2015 11:52:15 PM

Popular Answer

1
5/23/2017 12:14:40 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow