title: LINQ filter list based on property value and filter the properties as well
body: <p>My <code>NavigationItem</code> has navigation property <code>NavigationItemsPermissions</code> where I have <code>RoleId</code>. As input parameter in function I have <code>List&lt;int&gt; roleIds</code> where I will have something like {1, 3}.  </p>
  
  <p>How do I finish my <code>LINQ</code> to give me back <code>NavigationItem</code>(s) that has <code>NavigationItemsPermissions</code> with <em>some</em> <code>RoleId</code> on the input list. <strong>Note</strong> that, additionally, I want only those <code>NavigationItemsPermissions</code> with <code>RoleId</code> from the input list.</p>
  
  <p>Here is where I'm stuck at</p>
  
  <pre><code>public List&lt;NavigationItem&gt; GetNavigationItems(MenuType menuType, List&lt;int&gt; roleIds)
  {
      var navigationItems = DbContext.NavigationItems.Where(x =&gt; x.MenuTypeId == (int) menuType &amp;&amp; !x.IsDeleted &amp;&amp; x.NavigationItemsPermissions.Any(r=&gt;r.RoleId **in roleIds**)));       
  
      return navigationItems;
  }
  </code></pre>
  
  <p>To give a simpler analogy (not real data), if there is a list of developers</p>
  
  <pre><code>developers: [
      { name: "Hickory", skills: ["c#", "js", "linq"] }
      { name: "Dickory", skills: ["html", "css", "js"] }
      { name: "Dock", skills: ["html", "c#", "oracle"] }
  ]
  </code></pre>
  
  <p>And a given list of skills <code>list = [ "c#", "linq" ]</code>, I want the following as result</p>
  
  <pre><code>[{ name: "Hickory", skills: ["c#", "linq"] }
  { name: "Dock", skills: ["c#"] }]
  </code></pre>
  
  <p>Sample real data:</p>
  
  <p><a href="https://i.stack.imgur.com/iykYL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iykYL.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/bEVjB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bEVjB.png" alt="enter image description here"></a></p>
  
  <p>Thank you for any help.</p>