[英]Multiple models in one controller vs Many partial views
I was just curious, what is considered to be better? 我只是好奇,什么被认为更好? Multiple models into one Controller - ie, a Controller performing business access on many models and then passing those results to a view, OR
将多个模型集成到一个Controller中-即,一个Controller对多个模型执行业务访问,然后将这些结果传递给视图,或者
One model per controller, with many partial views, and with Controller actions linking the controllers together? 每个控制器一个模型,具有许多局部视图,并且具有将控制器链接在一起的控制器动作?
A controller may use MANY models. 控制器可以使用许多模型。
yet a view can have only 1 model passed into it which is called ViewModel. 但是视图只能传递1个称为ViewModel的模型。
So maybe you can say, 1 Output ViewModel Per ActionResult, yet as you mentioned within the action result, you may use4 many models and the result will boil down to the Output ViewModel 因此,也许您可以说,每个ActionResult 1个输出ViewModel,但是正如您在动作结果中提到的那样,您可以使用4个模型,并且结果将归结为Output ViewModel
the model that goes to the partialview, may be exact same as the model for the parent view or a child object of the model of the parent view. 进入偏视图的模型可能与父视图的模型或父视图模型的子对象完全相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.