1

I am just curious about "@model dynamic" in mvc 3. Correct me if I am wrong but if you use this on a particular view then in your controller you can do this:

public ActionResult RandomView(int number)
{
    if (number == 5)
    {
       ModelFive model = new ModelFive();
       return View(model);
    }

    if (number == 6)
    {
       ModelSix model = new ModelSix();
       return View(model);
    } 
 }

I there anything else I am missing with 'dynamic' keyword? Somehow i did not find any useful doc.

TheMentor
  • 464
  • 9
  • 25
  • Make one view model with the properties needed for RandomView? – Joe Jan 31 '12 at 12:51
  • Actually I was not aware of dynamic keyword before. So at first I thought it is meant only for model in mvc 3 and now i have figure that its actually something more. Take a look at http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28DYNAMIC_CSHARPKEYWORD%29;k%28TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22%29;k%28DevLang-CSHARP%29&rd=true – TheMentor Feb 01 '12 at 09:14

1 Answers1

2

take a look at this question. it goes through using the ExpandoObject to create a dynamic model.

Community
  • 1
  • 1
harryovers
  • 3,087
  • 2
  • 34
  • 56