本文介绍了搜索包含在同一文本框中搜索名字和姓氏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在文本框中搜索我的数据库,我想输入名字和姓氏并搜索,我的代码如下:
I am trying to search in my database in a textbox there I want to type firstname and lastname and search , my code looks as following,
using (var db = new knowitCVdbEntities())
{
var employee = (from p in db.EMPLOYEES
where
p.firstname.Contains(TextBoxSearch.Text) &&
p.lastname.Contains(TextBoxSearch.Text)
select p).ToList();
这样做我不能搜索名字和姓氏为什么?
Doing like this I cannot search for firstname and lastname why?
推荐答案
using (var db = new knowitCVdbEntities())
{
var employee = (from p in db.EMPLOYEES
where
p.firstname.Contains(TextBoxSearch.Text) ||
p.lastname.Contains(TextBoxSearch.Text)
select p).ToList();
快乐编码!
:)
Happy Coding!
:)
这篇关于搜索包含在同一文本框中搜索名字和姓氏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!