title: Linq To Entities: Checking Multiple Columns Against against a Set of Values
body: <p>I have a MySQL DB that I'm trying to query with the Entity Framework.</p>
  
  <p>I have a Match table that looks like this:</p>
  
  <p>match_id,  winning_hero1,  winning_hero2,  winning_hero3,  winning_hero4,  winning_hero5</p>
  
  <p>with a winning_hero being identified by an integer.</p>
  
  <p>given a list of hero ids, I want to return all matches where these heroes were all on the winning team together.</p>
  
  <p>something like this:</p>
  
  <pre><code>public List&lt;MatchEntity&gt; GetAllMatchesWithWinningHeroes(List&lt;int&gt; heroList)
      {
          List&lt;MatchEntity&gt; matchList = null;
          using (var context = new dotaEntities())
          {
              switch (heroList.Count)
              {
                  case 1:
                      matchList = context.MatchEntities.Where(m =&gt; m.winning_hero1 == heroList[0]
                                                                   || m.winning_hero2 == heroList[0]
                                                                   || m.winning_hero3 == heroList[0]
                                                                   || m.winning_hero4 == heroList[0]
                                                                   || m.winning_hero5 == heroList[0]).ToList();
                      break;
                  case 2:
                      matchList = context.MatchEntities.Where(m =&gt; (m.winning_hero1 == heroList[0]
                                                                   || m.winning_hero2 == heroList[0]
                                                                   || m.winning_hero3 == heroList[0]
                                                                   || m.winning_hero4 == heroList[0]
                                                                   || m.winning_hero5 == heroList[0])
                                                                   &amp;&amp; (m.winning_hero1 == heroList[1]
                                                                   || m.winning_hero2 == heroList[1]
                                                                   || m.winning_hero3 == heroList[1]
                                                                   || m.winning_hero4 == heroList[1]
                                                                   || m.winning_hero5 == heroList[1])).ToList();
                      break;
                  case 3:
                      //etc..
              }
  
              return matchList;
          }
      }
  </code></pre>
  
  <p>Is there a "nicer" way to go about selecting these matches?</p>
  
  <p>Thank you.</p>