title: MVC to MVC2 Errors
body: <p>I've just updated to VS2010 (rc) and subsequently been forced to update my projects and convert to MVC2 (ta microsoft)... which has scuppered the first app its touched.</p>
  
  <pre><code>Error   2   'System.Web.Mvc.IValueProvider' does not contain a definition for
  'Where' and no extension method 'Where' accepting a first argument of type 
  'System.Web.Mvc.IValueProvider' could be found (are you missing a using directive or an 
  assembly reference?)    ~\Controllers\DiscountsController.cs    51  39  ODSe
  </code></pre>
  
  <p>Considering I know this works in VS2008 - MVC1 I'm a tad thrown. Anyone?</p>
  
  <p>I currently have (included)</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using System.Web.Mvc.Ajax;
  using ODSe.Models;
  using System.Text;
  using System.Text.RegularExpressions;
  using System.Net.Mail;
  </code></pre>
  
  <p>Shouldnt need to be .net 4 as the original project was 3.5; and MVC2 is .net 3.5
  (ASP.NET MVC 2 RC 2 provides a new Model-View-Controller (MVC) framework on top of the existing ASP.NET 3.5 SP1 runtime.)</p>
  
  <p><strong><em>Code Around 51</em></strong></p>
  
  <pre><code>foreach (var x in this.ValueProvider.Where(k =&gt; k.Key.StartsWith("discount.")))
  {
     if (String.IsNullOrEmpty(x.Value.AttemptedValue))
     {
       ModelState.SetModelValue(x.Key, new ValueProviderResult(ValueProvider[x.Key].AttemptedValue, collection[x.Key], System.Globalization.CultureInfo.CurrentCulture));
                          Discount = true;
     }
  }
  </code></pre>
  
  <p>When the code was written for MVC(1) in VS2008 this.ValueProvider was "IDictionary ControllerBase.ValueProvider. 
  In MVC(2) VS2010 it throws a hissy fit about using where though this is apparently fine.</p>
  
  <pre><code>foreach (var x in this.ValueProvider)
                      {
                          if (x.Key.StartsWith("discount."))
                          {
                              if (String.IsNullOrEmpty(x.Value.AttemptedValue))
                              {
                                  ModelState.SetModelValue(x.Key, new ValueProviderResult(ValueProvider[x.Key].AttemptedValue, collection[x.Key], System.Globalization.CultureInfo.CurrentCulture));
                                  Discount = true;
                              }
                          }
                      }
  </code></pre>
  
  <p>If not a butt ugly piece of code; Legacy Code is soooo much fun</p>