ASP.NET MVC: search in data entry form

前端 未结 3 756
感动是毒
感动是毒 2021-02-10 16:39

and thanks for reading.

I am building a data entry form. I am trying to figure out a way to let the user to provide a criteria (last name for instance), search the emplo

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-10 17:06

    I suggest using Linq.

    Consider Scott Gu's Example blog........

    http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx

    public static void GetEmployeeIDByLastName(string lastName)
    {
    
    DataContext dc = new DataContext();
    
    var queryResult = from q in dc.Employee
                where q.EmployeeLastName.Equals(lastName)
                select new {
                    EmployeeID = q.EmployeeID
                          }
    
    foreach(var empID in queryResult)
            {
                 //pass the empID value back to the display
            }
    }
    

提交回复
热议问题