This is my employee table and it contain 2 fields called EmployeeID and DisplayName . EmployeeID is primary key. What i need is i want to retrieve these tables values one by one and assign that values (Which i retrieve one by one from table ) to variables.
Eg
var1 = yasin var2 = rajan.. I tried one method . In that method i gave hardcode to find each Id one by one. But hardcode is not correct way for professional developer right.
var yasinempid = (from emp in db.Employees where emp.DisplayName == "Yasin" select emp.EmployeeID).FirstOrDefault();Now i want to find the ID of yasin employee.so i gave yasin value directly in the query. But this is not correct way because i have limited no of employees so i can able to find employee ID easily . But i have lot of employees means this hardcode value is not correct way and also it wont give correct solution right . So that i need alternate solution for this problem.
I tried my level best to explain this issue. Any one understand my issue and help me to resolve this problem.
Advance thanks.
Sneha KPosted Oct 24, 2016, 10:01 AM
Francis SusaimichaelPosted Oct 24, 2016, 9:06 AM
Sneha KPosted Oct 24, 2016, 9:03 AM
Francis SusaimichaelPosted Oct 24, 2016, 8:49 AM
I hopeyou want to loop thru theList of Employees and get the employees name andid. If so, try the below: