Monday, 26 August 2013

How to map a list of IDs into a lookup table with Automapper

How to map a list of IDs into a lookup table with Automapper

I have a DB tables called Departments, Users and DepartmentUsers
I want to allow the management of which Users belong to each Department.
I have a viewmodel which has
int DeptId
List<int> UserIds
and this helps show all users and whether they belong to this department
When I submit the form with the DeptId in the url, I want to update the
DepartmentUsers table with the newly selected users for this department
(some may have been de-selected)
How do I do this with AutoMapper? Prior to using AutoMapper, I'd have
cleared out the DepartmentUsers table for the selected DeptId and then
added them all back in again. I've been using AutoMapper for everything
else and would prefer to use it for this too

No comments:

Post a Comment