我需要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