0

Here is code example of what i am asking.

    public ActionResult Action()
    {
        object person = new Person(); //It works if i replace object with Person
        UpdateModel(person); //this does not update person because of "object" declaring type

        return View();
    }

What is best way to update model if if i determine model type at runtime ?

Freshblood
  • 6,285
  • 10
  • 59
  • 96
  • See it http://stackoverflow.com/questions/7436822/update-model-from-database-does-not-see-a-type-change –  Jul 13 '13 at 04:30

1 Answers1

1

To resolve at runtime (although not evident why you'd need to, from what you've posted), then use dynamic:

dynamic person = new Person();   // resolves at runtime -- no point in doing this,
                                 // since the type is known at compile time anyway
McGarnagle
  • 101,349
  • 31
  • 229
  • 260