<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Database.AddDBObject vs. TransactionManager.AddNewlyCreatedDBObject in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/database-adddbobject-vs-transactionmanager/m-p/12718911#M4396</link>
    <description>&lt;P&gt;AddDBObject appends an object to the database, but it has no owner, orphaned objects may not be saved. So, you should avoid AddDBObject unless you have a specific reason to use it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BlockTableRecord.AppendEntity appends an object to the database AND applies an owner, which in this case, is the BlockTableRecord, such as modelspace or paperspace&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AddNewlyCreatedDBObject is a transaction, this for more for memory management, undo redo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 19 Apr 2024 01:52:44 GMT</pubDate>
    <dc:creator>daniel_cadext</dc:creator>
    <dc:date>2024-04-19T01:52:44Z</dc:date>
    <item>
      <title>Database.AddDBObject vs. TransactionManager.AddNewlyCreatedDBObject</title>
      <link>https://forums.autodesk.com/t5/net-forum/database-adddbobject-vs-transactionmanager/m-p/12716909#M4393</link>
      <description>&lt;P&gt;Is there any difference in usage between Database.AddDBObject and TransactionManager.AddNewlyCreatedDBObject? I recently made a mistake (if there are two identically defined methods, one is a native method and the other is an extended method, no prompt will be given...), I am considering writing a demo to analyze and verify, and submit it to Microsoft, think about design rationality).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because I had never used AddDBObject and had no impression of it, I accidentally wrote an extension method with the same name and the same parameter list, causing an error in the method I wanted to execute.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Share my method:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;    public static void AddDBObject(this Database db, DBObject obj)
    {
        if (!db.IsValid())
            throw new InvalidDataException(nameof(db));

        if (!obj.IsValid())
            throw new InvalidDataException(nameof(obj));

        db.GetTopTransaction().AddNewlyCreatedDBObject(obj, true);
    }&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 18 Apr 2024 10:16:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/database-adddbobject-vs-transactionmanager/m-p/12716909#M4393</guid>
      <dc:creator>kelidesign</dc:creator>
      <dc:date>2024-04-18T10:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Database.AddDBObject vs. TransactionManager.AddNewlyCreatedDBObject</title>
      <link>https://forums.autodesk.com/t5/net-forum/database-adddbobject-vs-transactionmanager/m-p/12717341#M4394</link>
      <description>&lt;P&gt;AddDBObject() adds an object to the Database.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AddNewlyCreatedDBObject() adds an object to the transaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One has nothing to do with the other.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You rarely need to call AddDBObject() because adding a DBObject to an owner (e.g., &lt;A href="https://help.autodesk.com/view/OARX/2024/ENU/?guid=OARX-ManagedRefGuide-Autodesk_AutoCAD_DatabaseServices_BlockTableRecord_AppendEntity__CallerMustClose__Entity" target="_blank" rel="noopener"&gt;BlockTableRecord.AppendEntity&lt;/A&gt;) also adds it to the Database.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2024 13:09:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/database-adddbobject-vs-transactionmanager/m-p/12717341#M4394</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-04-18T13:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: Database.AddDBObject vs. TransactionManager.AddNewlyCreatedDBObject</title>
      <link>https://forums.autodesk.com/t5/net-forum/database-adddbobject-vs-transactionmanager/m-p/12718884#M4395</link>
      <description>I still can't intuitively feel the difference and when to use it. It would be great if I could explain a specific example. Thanks.</description>
      <pubDate>Fri, 19 Apr 2024 01:36:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/database-adddbobject-vs-transactionmanager/m-p/12718884#M4395</guid>
      <dc:creator>kelidesign</dc:creator>
      <dc:date>2024-04-19T01:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: Database.AddDBObject vs. TransactionManager.AddNewlyCreatedDBObject</title>
      <link>https://forums.autodesk.com/t5/net-forum/database-adddbobject-vs-transactionmanager/m-p/12718911#M4396</link>
      <description>&lt;P&gt;AddDBObject appends an object to the database, but it has no owner, orphaned objects may not be saved. So, you should avoid AddDBObject unless you have a specific reason to use it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BlockTableRecord.AppendEntity appends an object to the database AND applies an owner, which in this case, is the BlockTableRecord, such as modelspace or paperspace&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AddNewlyCreatedDBObject is a transaction, this for more for memory management, undo redo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2024 01:52:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/database-adddbobject-vs-transactionmanager/m-p/12718911#M4396</guid>
      <dc:creator>daniel_cadext</dc:creator>
      <dc:date>2024-04-19T01:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: Database.AddDBObject vs. TransactionManager.AddNewlyCreatedDBObject</title>
      <link>https://forums.autodesk.com/t5/net-forum/database-adddbobject-vs-transactionmanager/m-p/12720648#M4397</link>
      <description>&lt;P&gt;I would suggest finding a better language translator.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2024 16:19:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/database-adddbobject-vs-transactionmanager/m-p/12720648#M4397</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-04-19T16:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: Database.AddDBObject vs. TransactionManager.AddNewlyCreatedDBObject</title>
      <link>https://forums.autodesk.com/t5/net-forum/database-adddbobject-vs-transactionmanager/m-p/12725344#M4398</link>
      <description>Sorry, it may have something to do with the simplicity of my expression. I will pay attention to it, thank you.</description>
      <pubDate>Mon, 22 Apr 2024 15:05:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/database-adddbobject-vs-transactionmanager/m-p/12725344#M4398</guid>
      <dc:creator>kelidesign</dc:creator>
      <dc:date>2024-04-22T15:05:14Z</dc:date>
    </item>
  </channel>
</rss>

