Question

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);
Was it helpful?

Solution

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

AutoMapper.Mapper.Map<ObjQ , ObjQ >(srcQ, objq);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top