我需要return
ID
的人员(雇员),具体取决于中写入的username
。 我的逻辑是从textbox
获取username
,检查database
table
,然后return
ID
找到的用户名。 但是,我不知道如何返回PersonID
,任何人都可以提供帮助,因为我发现的研究是returning
的价值inserted
table
而不是我的情况。比较不同列的值后字段的返回ID
业务逻辑代码:
public List<Person> getEmployeeByID(string empName)
{
LinqToSqlDataContext database = new LinqToSqlDataContext();
return database.Persons.Where(emp => emp.personName.Contains(empName)).ToList();
//return the ID of the person which carries the textbox's name
}
谢谢!
是'empName'在人表中唯一吗? – Manoj