public List <AdminProfileViewModel> GetEmployeeByDepartmentID(int DepartmentId) { List <Employee> employeelist = er.GetEmployeeByDepartmentID(DepartmentId); var config = new MapperConfiguration(cfg => { cfg.CreateMap <Employee, AdminProfileViewModel>(); cfg.CreateMap <Department, DepartmentViewModel>(); cfg.IgnoreUnmapped(); }); IMapper mapper = config.CreateMapper(); List <AdminProfileViewModel> emplist = mapper.Map <List <Employee>, List <AdminProfileViewModel> >(employeelist); return(emplist); }