如何使用实体框架和razor引擎向我的表添加过滤器? [英] How do I add filter to my table using entity framework and razor engine?

查看:70
本文介绍了如何使用实体框架和razor引擎向我的表添加过滤器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个MVC5应用程序从我的SQL Server表中获取数据并使用Razor引擎在cshtml上输出。我刚刚使用了visual studio 2013在添加新项目时创建的自动生成的代码。我想添加一个链接,创建一个过滤器和表的排序。我不知道如何用Razor做到这一点。



这是我的控制器:



< pre lang =Javascript> private AH_ODS_DB_Entities db = new AH_ODS_DB_Entities();

// 获取:/ Home /
public ActionResult Index()
{
return 查看(db.Transmitals.ToList()) ;
}





有关MVC5,entityframework或Razor引擎的书的任何建议?

解决方案

看看这里: MVC 4 - 如何在视图中将linq返回到实体查询结果 [ ^ ],这里:MVC5 Linq to ViewModel to Razor查看代码改进? [ ^ ]



示例代码: ASP.NET MVC 5 - 与实体的CRUD操作Visual Studio 2013上的框架 [ ^ ]

Hi,

I have an MVC5 application that gets data from my SQL Server table and outputs it on cshtml using Razor engine. I just used the auto-generated code that visual studio 2013 created when I added a new item. I want to add a link that creates a filter and sorting of the table. I'm not sure how to do that with Razor.

Here is my controller:

private AH_ODS_DB_Entities db = new AH_ODS_DB_Entities();

// GET: /Home/
public ActionResult Index()
{
    return View(db.Transmitals.ToList());
}



Any recommendations for a book about MVC5, entityframework or Razor engine?

解决方案

Have a look here: MVC 4 - How to return a linq to entity query result in a view[^] and here: MVC5 Linq to ViewModel to Razor View code improvement?[^]

Sample code: ASP.NET MVC 5 – CRUD operations with Entity Framework 6 on Visual Studio 2013[^]


这篇关于如何使用实体框架和razor引擎向我的表添加过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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