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?
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.
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.
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).
You can use:
var test = context.Tests .Include("Question.QuestionLocale") .FirstOrDefault();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With