Win7 AutoCAD2012 VS2010:
I've searched for this quite a bit and cannot find a definite answer.
Do you always have to call trans.Commit(); on any transaction that you start?
Even if it's just to openMode.ForRead objects for informational purposes without changing anything in the database?
Example: I'm returning the ObjectId's for a calling method, do I need to call trans.Commit() before the using ends?.
private static ObjectId[] GetGroupObjectIDs()
{
Document document = AcadApp.DocumentManager.MdiActiveDocument;
Editor editor = document.Editor;
Database database = HostApplicationServices.WorkingDatabase;
ObjectId[] EntIds = null;
ObjectId oid = PickGroupInDrawing.SelectEntityOfGroup();
if (!oid.IsNull)
{
using (document.LockDocument())
{
using (Transaction trans = database.TransactionManager.StartTransaction())
{
ObjectId gid = GetGroupIdFromEnt(oid, trans);
if (!gid.IsNull) //GroupId.
{
Group grp = trans.GetObject(gid, OpenMode.ForWrite, false) as Group; //is group.
if (grp != null)
{
DBDictionary GrpDic = (DBDictionary)trans.GetObject(database.GroupDictionaryId, OpenMode.ForRead);
EntIds = grp.GetAllEntityIds();
}
}
}
}
}
return EntIds;
}
TIA