https://github.com/chsword/searchmodel
https://github.com/chsword/searchmodel
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/chsword/searchmodel
- Owner: chsword
- Created: 2017-04-07T10:47:26.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-07T10:50:56.000Z (about 9 years ago)
- Last Synced: 2025-12-26T09:57:53.290Z (5 months ago)
- Language: C#
- Size: 635 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SearchModel
*Project Description*
{project:description}
You can use the code like this in ASP.NET MVC View
{code:aspx c#}
Name:@Html.TextBox("Name").ForSearch(QueryMethod.Like)
Email:@Html.TextBox("Email").ForSearch(QueryMethod.Equal)
Id: @Html.TextBox("Id").ForSearch(QueryMethod.Equal)
Birth: @Html.TextBox("Birthday").ForSearch(QueryMethod.Equal)
@{
var grid = new WebGrid(Model);
@grid.GetHtml();
}
{code:aspx c#}
And use the code in Controller
{code:C#}
public ActionResult Index(QueryModel model)
{
using(var db=new DbEntities())
{
var list = db.Users.Where(model).ToList();
return View(list);
}
}
{code:C#}
To convert the form field to the entity framework query expression.
[url:@chsword on Weibo.com|http://weibo.com/chsword]
[url:linkedin|http://lnkd.in/b6vqP_c]