This is a migrated thread and some comments may be shown as answers.
AttachCopy throwing NotImplementedException
2 Answers 12 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Paulo
Top achievements
Rank 1
Paulo asked on 04 Nov 2013, 06:13 PM
Hello!

I'm trying to update an entity on database using the AttachCopy method, but i'm getting the following error:


   at OpenAccessRuntime.common.GenericState.UnresolveForCompare(Object x, FieldMetaData fmd, OpenAccessPersistenceManagerImp pm)
   at OpenAccessRuntime.common.GenericState.Equals(State o, Int32 stateFieldNo, OpenAccessPersistenceManagerImp myPm, OpenAccessPersistenceManagerImp otherPm)
   at Telerik.OpenAccess.Runtime.Detached.AttachOperation.FindChanges(Boolean[] filled, State detached, OpenAccessPersistenceManagerImp detachedPM, State online, Int32 ignoreCC)
   at Telerik.OpenAccess.Runtime.Detached.AttachOperation.AttachCopyImplDetached(OpenAccessPersistenceManagerImp srcPM, PersistenceCapable src)
   at Telerik.OpenAccess.Runtime.Detached.AttachOperation.AttachCopyImpl(PersistenceCapable src, Boolean copy)
   at Telerik.OpenAccess.Runtime.Detached.AttachOperation.AttachCopies()
   at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.AttachCopies(ArrayList persistentObjects)
   at OpenAccessRuntime.DataObjects.UnsynchronizedPMProxy.AttachCopies(ArrayList persistentObjects)
   at OpenAccessRuntime.ObjectScope.AttachCopies(ArrayList persistentObjects)
   at Telerik.OpenAccess.OpenAccessContextBase.AttachCopy[T](T entity)

2 Answers, 1 is accepted

Sort by
0
Paulo
Top achievements
Rank 1
answered on 05 Nov 2013, 01:12 PM
I'm trying to update an object using the attach copy but this not works,

the method ToDbEntity updates the instance with values coming from the parameter object that's not the same type as telerik generates.

public void Save( T entity )
       {
           using ( DataContext context = new DataContext(this.connectionString) )
           {
               try
               {
                   using ( TransactionScope scope = ObterTransactionScope() )
                   {
                       TDb dbEntity = ( TDb ) db.CreateInstance(typeof(TDb).FullName);
                       dbEntity = db.AttachCopy<TDb>(dbEntity);
                       this.GetFactory().ToDbEntity(entity, dbEntity);                                         
                       db.SaveChanges();
                       scope.Complete();
                   }
               }
               catch
               {
                   throw;
               }
           }
       }
0
Alexander
Telerik team
answered on 06 Nov 2013, 02:42 PM
Hi Paulo,

Please, let's continue the communication in your other thread about the same problem, so the whole information is available at one place.

Regards,
Alexander
Telerik
OpenAccess ORM Q3 2013 simplifies your model operations even further providing you with greater flexibility. Check out the list of new features shipped with our latest release!
Tags
LINQ (LINQ specific questions)
Asked by
Paulo
Top achievements
Rank 1
Answers by
Paulo
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or