I was previously using http://stackoverflow.com/questions/762825/how-can-a-formcollection-be-enumerated-in-asp-net-mvc 's implementation but now I'm on VS2010 and MVC2 its complaining:
Error 1 Cannot implicitly convert type 'System.Web.Mvc.IValueProvider' to 'System.Collections.Generic.IDictionary'. An explicit conversion exists (are you missing a cast?) C:\~\ProjectMVC\Controllers\TheController.cs line ProjectMVC
The code is ...
IDictionary<string, ValueProviderResult> tmpCollection = collection.ToValueProvider();
for (int j = 1; j <= noprops; j++)
{
string shopNmTmp =
(from t in tmpCollection
where t.Key.StartsWith(j + ".discount.sname." + j)
select t.Value.AttemptedValue).First();
string shopCdTmp =
(from t in tmpCollection
where t.Key.StartsWith(j + ".discount.sref." + j)
select t.Value.AttemptedValue).First();
...
Did something change when I wasn't looking; this compiles and works and runs and has no issues in MVC1; but wont compile in 2.
Thanks
Update
I techically just fixed this by using:
Dictionary<string, string> tmpCollection = collection.AllKeys.ToDictionary(k => k, v => collection[v]);
instead.
But I'd still be interested in why it changed between versions.