Apologies for the clunky title. I need to query a collection and return the grandparent, parent and grandchild based on a grandchild’s property
For example with the object below, I want to get the Quote, the Rate (Parent) and the Plan (GrandChild) only if a condition matches the Plan’s ID.
public class Quote
{
public int Id { get; set; }
public string Type { get; set; }
public string ParentType { get; set; }
public decimal ValueMax { get; set; }
public virtual ICollection<Rate> Rates { get; set; }
}
public class Rate
{
public int Id { get; set; }
public decimal ValueMax { get; set; }
public ICollection<Plan> Plans { get; set; }
}
public class Plan
public int Id { get; set; }
public decimal Price { get; set; }
}
You should be able to do something like this to get the plans which meet whatever criteria, along with their parent and grandparent objects: