我正在尝试在ASP.NET.MVC中创建一个搜索框,我可以在其中基于名字,姓氏,电话,地址或电子邮件进行搜索。我在从数据库中检索数据的位置创建了变量,但是当我尝试return View()
时,这将显示错误。我知道如何解决它的任何想法,因为我需要根据所有这些条件进行搜索。
public ActionResult Search(string searching)
{
var F_N = db.Contacts.Where(x => x.FirstName.Contains(searching));
var L_N = db.Contacts.Where(x => x.LastName.Contains(searching));
var P_N = db.Phones.Where(x => x.PhoneNumber.Contains(searching));
var E_A = db.Emails.Where(x => x.EmailAddress.Contains(searching));
var A_N = db.Addresses.Where(x => x.AddressName.Contains(searching));
return View((F_N || L_N || P_N || E_A || A_N || searching == null).ToList());
}