Actually I see now that the idea is a little bit different. You should add mapping only for departments:
ADS_Departements.Close;
FreeAndnil(Departements_List);
Departements_List := DM_DataAccess.ClientXData.List<Tecl_departement>;
for departement in Departements_List do
if not Map.IsIdMapped(departement) then
Map.Add(departement);
ADS_Departements.SetSourceList(Departements_List);
ADS_Departements.Open;
Then after this, for customers, what you should do is replace the departments that are already mapped. Something like this:
ADS_Users.close;
FreeAndnil(Users_List);
Users_List := DM_DataAccess.ClientXData.List<Tecl_utilisateur>;
for User in Users_List do
if Map.IsIdMapped(User.departement_id) then
User.departement_id := Tecl_departement(Map.GetById(Tecl_departement, User.departement_id.id));
ADS_Users.SetSourceList(Users_List);
ADS_Users.Open;
That should ok. You only need one Map
for all objects, and you create it by passing the TMappingExplorer
object:
Map := TObjectMap.Create(TMappingExplorer.Default);