I have such relations:
class FirstParent {
public SecondParent SecondRecord { get; set; }
}
class SecondParent {
public IEnumerable<FirstParent> FirstRecords { get; set; }
}
class FirstChild1 : FirstParent {
public String StrInFirstChild1{ get; set; }
}
class SecondChild1 : SecondParent {
public String StrInSecondChild1{ get; set; }
}
class FirstChild2 : FirstParent {
public String StrInFirstChild2{ get; set; }
}
class SecondChild2 : SecondParent {
public String StrInSecondChild2{ get; set; }
}
Records related to class FirstChild1 are of type SecondChild1.
Records related to class FirstChild2 are of type SecondChild2.
When I write
var record = from ch in context.FirstParent.OfType<FirstChild1>() select ch.SecondRecord;
in result I also have SecondParent object.
What is happening? How to load SecondChild1 objects?
I found a resolution. I load records from all four tables and do join to collect needed information to anonymous object.