I have a below scenario
Assuming that there are 3 departments,
For employee no 100 I want to all the departments
For employee no 200 I want dept 1,2
For employee no 300 I want only dept 3
In future if some employees needs dept 1,2 I should be able
to accommodate this without changing the code.
Please suggest efficient code for this.
I don't understand your requirement in several points.
What do you mean by "for employee no. xxx I want ??? departments"? Please explain with an example.
Second, what's the rule which departments shall be "assigned" to which employee? Is this a hard-coded rule or something which may vary from employee to employee?