0

I am trying to update an object using telerik openaccess orm and automapper, it works for adding the object to scope but not update.

I saw on their site someone having same issue, but the answer didn't really help me. here is my code which doesn't update my object :

try
            {
                if (!scope.Transaction.IsActive)
                    scope.Transaction.Begin();

                ObjQ objq = get_Q(scope, Id);
                bool isNew = false;

                if (objq == null)
                {
                    objq = new ObjQ();
                    isNew = true;
                }

                AutoMapper.Mapper.CreateMap<ObjQ , ObjQ >();

                objq = AutoMapper.Mapper.Map<ObjQ , ObjQ>(srcQ);

                if (isNew)
                {
                    scope.Add(objq);
                }

                scope.Transaction.Commit();

                success = true;
            }

after this line I can see my properties reflecting the new changes but it is not the same in database

objq = AutoMapper.Mapper.Map<ObjQ , ObjQ>(srcQ);
Zaki
  • 5,540
  • 7
  • 54
  • 91

1 Answers1

0

for anyone else who wants to do the same thing, managed to do it this way:

AutoMapper.Mapper.Map<ObjQ , ObjQ >(srcQ, objq);
Zaki
  • 5,540
  • 7
  • 54
  • 91
  • Well, I have to say that in my case, I came to find that Telerik Data Access doesn't like AutoMapper (or ValuInjecter for that matter). This code does not work: OBJ.Manutencao dbManutencao = this.mManutencaoRepository.Get(manutencao.ManutencaoID); { Mapper.Reset(); Mapper.CreateMap(); Mapper.Map(manutencao, dbManutencao); this.mUnitOfWork.SaveChanges(); return true; Some properties do not get correctly mapped. – Stargazer Mar 08 '14 at 13:13