Is model binding possible without mvc?

后端 未结 2 1608
走了就别回头了
走了就别回头了 2021-01-16 09:43

Say I have a Dictionary and I want to update an object with the values from the dictionary, just like model binding in MVC... how would yo

2条回答
  •  一整个雨季
    2021-01-16 10:11

    You can do that, but you would still need to reference System.Web.Mvc, obviously. It is more or less a matter of constructing a ModelBinder, perhaps the DefaultModelBinder, then call it with the appropiate arguments - but those arguments, unfortunately, is very closely bound to the web scenario.

    Depending on what you exactly want, it might make more sense to roll your own simple reflection based solution.

提交回复
热议问题