title: LINQ Query using 'StartsWith' with an array
body: <p>In My LINQ Query I use Where Clauses to check whether a property exists within an array of values. I would like to update the query:</p>
  
  <pre><code>string[] itemColour
  string[] itemType
  
  List&lt;displayItem&gt; displayItems = (from item in allItems
                                    Where itemColour.Contains(item.colour)
                                    Where itemType.Contains(item.type)
                                    select new displayItem
                                    ......................etc...etc
  </code></pre>
  
  <p><strong>So what I have is</strong> </p>
  
  <p>'Where my 'itemColour' array contains this 'item.colour' select it'</p>
  
  <p>'Where my 'itemType' array contains this 'item.type' select it'</p>
  
  <p><strong>What I'm after is</strong> </p>
  
  <p>'Where my 'itemColour' array has an item that has 'item.colour' anywhere in it select it<br>
  'Where my 'itemType' array has an item that begins with 'item.type' select it</p>
  
  <p>I'm aware of 'StartsWith' and 'EndsWith' but don't know how to use them with these arrays.</p>
  
  <p><strong>note:</strong> itemColour may contain an item that has the colour code 'RGW' I would want to be able to select this item based on any of the three letters</p>
  
  <p><strong>Update</strong></p>
  
  <p>The suggested solution : </p>
  
  <pre><code>var query = from item in allItems
          where itemColour.Any(c =&gt; c.Contains(item.colour))
             &amp;&amp; itemType.Any(t =&gt; t.StartsWith(item.type)
          select ...;
  </code></pre>
  
  <p>has an issue. If I'm trying to bring back an item with the colour Code 'RB'. 
  My Array may contain two items 'R' and 'B' the suggested query is only returning items with colour code either 'R' or 'B' not both.</p>
  
  <p>I am using MVC 5, LINQ TO Entity, .NET 4.5</p>
  
  <p>Thanks</p>