Exemplo n.º 1
0
        // Writes the given object to the database.
        public void Commit(DatabaseTable dbObject)
        {
            if (dbObject == null)
            {
                return;
            }

            if (dbObject.CommitInProcess)
            {
                return;
            }

            if (dbObject.DBManager == null)
            {
                dbObject.DBManager = this;
            }

            dbObject.CommitInProcess = true;

            if (dbObject.CommitNeeded)
            {
                verifyTable(dbObject.GetType());

                dbObject.BeforeCommit();

                if (dbObject.ID == null)
                {
                    insert(dbObject);
                }
                else
                {
                    update(dbObject);
                }
            }

            CommitRelations(dbObject);

            dbObject.CommitInProcess = false;
            dbObject.CommitNeeded    = false;
            dbObject.AfterCommit();
        }