LINQ select all items of all subcollections that contain a string <p>I'm using jqueryui autocomplete to assist user in an item selection. I'm having trouble selecting the correct items from the objects' subcollections.<br> Object structure (simplified) is</p> <pre><code>public class TargetType { public int Id { get; set; } public string Name { get; set; } public virtual ICollection&lt;SubCategory&gt; SubCategories { get; set; } public TargetType() { SubCategories = new HashSet&lt;SubCategory&gt;(); } } public class SubCategory { public int Id { get; set; } public string Name { get; set; } public virtual ICollection&lt;SubTargetType&gt; SubTargetTypes { get; set; } public SubCategory() { SubTargetTypes = new HashSet&lt;SubTargetType&gt;(); } } </code></pre> <p>Currently I'm doing this with nested foreach loops, but is there a better way?<br> Current code:</p> <pre><code>List&lt;SubTargetResponse&gt; result = new List&lt;SubTargetResponse&gt;(); foreach (SubCategory sc in myTargetType.SubCategories) { foreach (SubTargetType stt in sc.SubTargetTypes) { if (stt.Name.ToLower().Contains(type.ToLower())) { result.Add(new SubTargetResponse { Id = stt.Id, CategoryId = sc.Id, Name = stt.Name }); } } } </code></pre>