예제 #1
0
        private void SaveObjectPrivate(PersistentObject obj, ClassMap cm, IPersistenceProvider rdb)
        {
            IDbCommand cmd;

            if (obj.IsPersistent)
            {
                cmd = cm.GetUpdateSqlFor(obj);
                if (rdb.DoCommand(cmd) < 1)
                {
                    Assert.Fail(Error.ObjectUpdateFail, obj.GetClassName() + "Object update failed!");
                }
            }
            else
            {
                cmd = cm.GetInsertSqlFor(obj);
                if (cm.Table.AutoIdentityIndex < 0)
                {
                    rdb.DoCommand(cmd);
                }
                else
                {
                    object id;
                    rdb.InsertRecord(cmd, out id);
                    obj.SetAttributeValue(cm.AutoIdentityAttribute, id);
                }
            }
        }