日期:2014-05-17  浏览次数:20446 次

菜鸟求助,关于查询
菜鸟求助,如何在关键字查询中加入姓名和身份证号查询?

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 ....