a simple controller function
public class MyController : Controller
{
public List<int> GetList(dynamic viewbag)
{
return new List<int>();
}
public ActionResult Index()
{
var this_is_dynamic = GetList(this.ViewBag);
this_is_dynamic.Where(o => o == 0); //compile fail
var this_is_list = GetList(null);
this_is_list.Where(o => o == 0); //pass
object o = new object();
var this_is_list2 = GetList(o);
dynamic d = o;
var this_is_dynamic2 = GetList(d);
}
}
as my test shown, if I pass a non-dynamic to the function GetList(dynamic), the return result is expected: a List<int>
however, if I pass a dynamic to the function, compiler(VS 2012 Web Express target to .net 4.0) think the return result is dynamic instead of List<int>, thus I can't perform Linq query on dynamics.
...
Go to the complete details ...