title: Object reference not set to an instance of an object in linq to sql
body: <p>When running the following code I get the exception "System.Nullreferenceexception:object reference not set to an instance of an object". I believe it has something to with not initializing the allStudents variable but I'm not sure what type allStudents is.</p>
  
  <p>Any help is appreciated</p>
  
  <pre><code>    private void showStudents(string c)
      {
          try
          {
              using (SMDataClassesDataContext db = new SMDataClassesDataContext())
              {
  
                  var allStudents = from t in db.tbl_students
                                    where t.current_class == c
                                    select t;
                dgViewStudents.ItemsSource = allStudents;
              }
          }
          catch (Exception e)
          {
              MessageBox.Show(e.ToString());
          }
      }
  </code></pre>