当前位置: 代码迷 >> ASP.NET >> 初学者,关于查询
  详细解决方案

初学者,关于查询

热度:5479   发布时间:2013-02-25 00:00:00.0
菜鸟求助,关于查询
菜鸟求助,如何在关键字查询中加入姓名和身份证号查询?

C# code
public ActionResult Search(int? page, string keywords)        {            AppendTitle("个人会员-搜索结果");            var q = QueryBuilder.Create<Persons>()                .Like(x => x.UserName, keywords ?? string.Empty);            var query1 = QueryBuilder.Create<Persons>() //多字段查询                .Like(x => x.PersonNum, keywords ?? string.Empty);            q.Expression = q.Expression.Or(query1.Expression);            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;            var persons = personsRepository.Find(q, currentPageIndex, BaseControllerService.PageSize, "PersonID", false);            var viewModel = new PersonsIndexViewModel            {                Persons = persons,                Keywords = keywords            };            return View("Index", viewModel);        }





------解决方案--------------------------------------------------------
继续再like中增加你要查询的字段
------解决方案--------------------------------------------------------
做外链:
var query= from p in persons
join s in Pbaseinfo on p.Usernam equals s.UserName
where ....
  相关解决方案