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];It fails on the last line with "Object reference not set to an instance of an object" because the query returned no results.