Well, the one way i would approach is add "DepartmentID" property in the Employee class (like a foreign key). Add Employee to a List<employee> initially with "DepartmentID" null or 0 and then using your GUI, assign a Department to the employees i.e. populate the "DepartmentID" property and that's it. You don't need to have List<> in the data classes, they should only contain data for the individual entity. Operations should be separated out to business classes.
One Department can have many EMployees but one Employee can be in only one Department, its one to many relation and not a many to many (AFAIT).
Hope this helps.
[EDIT:]I really don't see a reason why my idea would be downvoted unless you or whoever downvoted it had a better solution or idea. Anyway, here is a little something to get you started. The following code shows 2 ways of doing of doing it (atleast in my world so far) - layered and unlayered:
public class Department
{
public int DepartmentID { get; set; }
public string DepartmentName { get; set; }
public string DepartDescription { get; set; }
}
public class Employee
{
public int EmployeeID { get; set; }
public string EmpFirstName { get; set; }
public string EmpLastName { get; set; }
public string EmpTitle { get; set; }
public int DepartmentId { get; set; }
}
static void Main(string[] args)
{
List<Department> departments = new List<Department>();
List<Employee> employees = new List<Employee>();
Department d = new Department();
d.DepartmentID = 1;
d.DepartmentName = "xyz";
d.DepartDescription = "abc";
departments.Add(d);
Department d1 = new Department();
d1.DepartmentID = 2;
d1.DepartmentName = "xyz2";
d1.DepartDescription = "abc2";
departments.Add(d1);
Employee e;
for (int i = 0; i < departments.Count; i++)
{
for (int j = 0; j < 4; j++)
{
e = new Employee();
e.DepartmentId = departments[i].DepartmentID;
e.EmpFirstName = "add";
e.EmpLastName = "test";
e.EmployeeID = 123;
e.EmpTitle = "adf";
employees.Add(e);
}
}
string employeename = employees.Where(x => x.DepartmentId == departments.Where(y => y.DepartmentName == "xyz").Select(y => y).FirstOrDefault().DepartmentID).Select(x => x.EmpFirstName).FirstOrDefault();
Console.WriteLine(employeename);
DepartmentBL dbl = new DepartmentBL();
for (int i = 0; i < departments.Count; i++)
{
for (int j = 0; j < 10; j++)
{
e = new Employee();
e.DepartmentId = departments[i].DepartmentID;
e.EmpFirstName = "add";
e.EmpLastName = "test";
e.EmployeeID = j+1;
e.EmpTitle ="adf" + (j+1).ToString();
dbl.EmployeeList.Add(e);
}
}
Console.WriteLine("Employees added :" + dbl.EmployeeList.Count.ToString());
}
Department and Employee data classes don't define any operation, that should be the task of a separate class (lookup n-tier architecture), in this case DepartmentBL (BL = Business Layer or Logic). It exposes an Employees list property that you can add Employees to, since a department "consists of" employees. Hope this helps to some extent.