title: compare collection values with returned values from database
body: <p>I have the following class:</p>
  
  <pre><code>    public class players
      {
          public void LottoDraw(object sender, EventArgs e)
          {
              var connectionstring = "Server=C;Database=lotto;User Id=lottoadmin;Password=password;";
  
  
              using (var con = new SqlConnection(connectionstring))  // Create connection with automatic disposal
              {
                  con.Open();
  
                  // Create new DataTable
                  DataTable player = new DataTable();
                  {
                      // Create new DataAdapter
                      using (SqlDataAdapter a = new SqlDataAdapter("SELECT TOP 1 LOTTOID, VAL0, VAL1, VAL2, VAL3, VAL4, VAL5 FROM tblLotto ORDER BY NEWID()", con))
                      {
                          // Use DataAdapter to fill DataTable
                          a.Fill(player);
                      }
                  }
              }
  
          }
          public int val0, val1, val2, val3, val4, val5, val6;
          public IEnumerable&lt;int&gt; Numbers
          {
              get
              {
                  return new[] { val0, val1, val2, val3, val4, val5, val6 };
              }
          }
  
      }
  }
  </code></pre>
  
  <p>It will return a random row from the database with some Lotto numbers. The values will then be put into a collection.</p>
  
  <p>I then want to use some Linq to compare the winning numbers with what is drawn.</p>
  
  <pre><code>public void LottoWinners(object sender, EventArgs e)
          {
  
              Dictionary&lt;int, int&gt; number = new Dictionary&lt;int, int&gt;();
              Random generator = new Random();
              while (number.Count &lt; 1)
              {
                  number[generator.Next(1, 49)] = 1;
              }
  
              string[] lotto = number.Keys.OrderBy(n =&gt; n).Select(s =&gt; s.ToString()).ToArray();
  
              var winners = players.
                  Where(Lotto =&gt; Lotto.Players.Numbers.Intersect(lotto).Count() &gt;= 3);
  
              //write some logic to find out who has 3 match numbers 
              //and assign there ticket to the winners table tblWinners
  
          }
  </code></pre>
  
  <p>However i get an error:</p>
  
  <p><strong>'Lotto.players' does not contain a definition for 'Where'</strong></p>
  
  <p>I already have: <code>using System.Linq;</code> in all my files!</p>