如何在asp.net mvc4中使用viewmodel执行分页 [英] How to perform paging with viewmodel in asp.net mvc4

查看:61
本文介绍了如何在asp.net mvc4中使用viewmodel执行分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在mvc4中创建了一个来自3个模型(表)的视图模型。当视频模型不支持来自控制器的视图页面列表。

i have create a viewmodel from 3 models(table) in mvc4.when data come from controller to view pagelist is not supported for a viewmodel.

推荐答案

理想情况下分页应该在存储过程中发生。



如果这是收集类型的数据,它看起来像,因为你正在组合3个模型来制作视图模型 - 那么我会说分页应该仍然发生在存储过程中,然后应相应地填充VM。



如果您没有存储过程并使用ORM,那么ORM应该进行分页并填充VM。在这种情况下,您不应再使用原始模型,只能直接使用VM传递数据。



希望这有帮助。
Ideally paging should happen in the stored procedure.

If this is collection sort of a data, which it appears like, because you are combining 3 models to make the view model - then I would say paging should happen still at the stored procedure and then the VM should be populated accordingly.

If you don't have stored procs and use an ORM instead, then the ORM should do the paging and populate the VM. In this case you should not use your original models any more and only use the VM directly to pass data.

Hope this helps.


这篇关于如何在asp.net mvc4中使用viewmodel执行分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆