Project Description
SearchModel is a tool for EF development in collaboration with ASP.NET

You can use the code like this in ASP.NET MVC View
<form action="" method="post">
Name:@Html.TextBox("Name").ForSearch(QueryMethod.Like)   
Email:@Html.TextBox("Email").ForSearch(QueryMethod.Equal)<br />
Id: @Html.TextBox("Id").ForSearch(QueryMethod.Equal)
Birth: @Html.TextBox("Birthday").ForSearch(QueryMethod.Equal)<br />
<input type="submit" value="search" />
</form>
@{
   var grid = new WebGrid(Model);
   @grid.GetHtml();
}
And use the code in Controller
        public ActionResult Index(QueryModel model)
        {
            using(var db=new DbEntities())
            {
                var list = db.Users.Where(model).ToList();
                return View(list);
            }
        }
To convert the form field to the entity framework query expression.

@chsword on Weibo.com
linkedin

Last edited Dec 31, 2013 at 2:27 AM by chsword, version 13