>>> >>>var query = from g in root.Groups >>> from r in g.Rules >>> from c in r.Conditions >>> from a in c.Actions >>> where g.Rules != null >>> where r.Conditions != null >>> where c.Actions != null >>> where a.ActionID == ActionId >>> select a; >>> >>>List<RuleAction> items = query.ToList(); >>>RetVal = items[0];>>>
>> >>RetVal = items.Count==0 ? null : items[0];>
>List<RuleAction> items = query.ToList(); >Not sure I've understood the underlying structure correctly but you might try something like this instead:
Action a = (from x in context.Actions .Include("Condition.Rule.Group.root") where x.Id == ActionId select x).FirstOrDefault();