c# - Closing AutoCAD objects which were obtained via transaction -


i'm writing autocad plugin. i'm using transaction objects , came question - need close (dispose) objects received via transaction?

it written in documentation when commit() method called transaction closes every object had been received via transaction.

void commit() -- function commits changes made in dbobjects opened during transaction, , closes them.

but happening when don't call method? example, i'm using transaction open object , receive layer name. following:

    database hostapp_workdb = hostapplicationservices.workingdatabase;     using ( application.documentmanager.mdiactivedocument.lockdocument() )     using ( transaction transaction = hostapp_workdb.transactionmanager.starttransaction() )     {         entity entity = transaction.getobject(objectid, openmode.forread) entity;          if ( entity != null )             layer = entity.layer;     } 

as can see, here don't call commit(). happen in case? entity closed or not (as transaction in using must disposed, suppose must close objects. haven't found confirmation of in documentation assumption).

maybe need this:

    objectid objectid = new objectid();     string layer = string.empty;      database hostapp_workdb = hostapplicationservices.workingdatabase;     using ( application.documentmanager.mdiactivedocument.lockdocument() )     using ( transaction transaction = hostapp_workdb.transactionmanager.starttransaction() )     {         using ( entity entity = transaction.getobject(objectid, openmode.forread) entity )         {             if ( entity != null )                 layer = entity.layer;         }     } 

links official sources encouraged.

thank you.

i remember reading post kean walmsley mentioned if don't use commit() transaction use abort() per default (i up).

entities automatically disposed if used in transaction. kean has nice examples on blog. should check them out. can find them here

you notifications in compiler output if entities have disposed.

edit:

forgetting commit transaction

[...] uncommitted transaction aborted when disposed, every change made database in transaction rolled [...]

it posted on adndevblog stephen preston here


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -