Entity Framework is a framework for creating entities. Another Navigation property's Include() navigation

.net entity-framework

Question

I have an entity Test. It contains a Navaigation Property Question and Question contains a Navigation Property QuestionLocale.

var test = context.Tests
       .Include("Question")
       .FirstOrDefault();

works as expected. But how is it possible to include the QuestionLocale?

1
33
3/30/2012 1:46:17 AM

Accepted Answer

You can use:


var test = context.Tests
                  .Include("Question.QuestionLocale")
                  .FirstOrDefault();

63
6/7/2019 3:33:21 AM

Popular Answer

You can do it in a strongly typed way too

var test = context.Tests
                .Include(x => x.Question.Select(child => child.QuestionLocale))
                .FirstOrDefault()


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