Expression<Func<Employee, bool>> employeeWhere = R => true;
employeeWhere = R => R.PositionCode == "M";
employeeWhere = R => R.IsActive; //want only ones which are true
Will the above build me a query of this :
SELECT * FROM EMPLOYEE
WHERE POSITIONCODE = "M" && IsActive = 1
This is what I want to return
var result = _db.Employees
.Where(employeeWhere)
.Select(p => new { p.EmployeeID, p.FName, p.MName, p.LName })
.AsEnumerable()
.ToDictionary(kvp => kvp.EmployeeID, kvp => kvp.FName + " " + kvp.MName + " " + kvp.LName);
return new SelectList(result, "Key", "Value");