Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework .Include() Navigation of another Navigation property

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?

like image 663
chbu Avatar asked Mar 05 '09 13:03

chbu


People also ask

How do I use navigation property in Entity Framework?

A navigation property is an optional property on an entity type that allows for navigation from one end of an association to the other end. Unlike other properties, navigation properties do not carry data. A navigation property definition includes the following: A name.

Does Entity Framework support foreign keys?

When you change the relationship of the objects attached to the context by using one of the methods described above, Entity Framework needs to keep foreign keys, references, and collections in sync.

How do I get navigation property in Entity Framework?

Need function like the following. private string[] GetNaviProps(Type entityType)//eg typeof(Employee) { NorthwindEntities en = new NorthwindEntities(); //here I return all Properties only for example return entityType. GetProperties(). Select(p=>p.Name).


1 Answers

You can use:

  var test = context.Tests                   .Include("Question.QuestionLocale")                   .FirstOrDefault();  
like image 92
Klinger Avatar answered Sep 27 '22 17:09

Klinger