Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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).
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.
Share my method:
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);
}
Solved! Go to Solution.