本帖最后由 lzh741206 于 2010-12-6 22:08 编辑
你还是写复杂了,呵呵
建议的方式,在子函数里不要新建事务,如果处理的实体较多,每开一个事务就会占耗时
正确的做法是传入事务作为参数,
- [CommandMethod("tttt")]
- public void tttt()
- {
- var db = HostApplicationServices.WorkingDatabase;
- var doc = Application.DocumentManager.GetDocument(db);
- var ed = doc.Editor;
- using (Transaction tr = doc.TransactionManager.StartTransaction())
- {
- ObjectIdCollection ids = new ObjectIdCollection();
- var cirs = GetEntitys<Circle>(tr, ids.Cast<ObjectId>());
- }
-
- }
- public IEnumerable<T> GetEntitys<T>(Transaction tr, IEnumerable<ObjectId> ids) where T : DBObject
- {
- return
- ids
- .Select(id => tr.GetObject(id, OpenMode.ForRead))
- .OfType<T>();
- }
|