예제 #1
0
        protected override void PerformAddOrUpdate(TypedEntity entity)
        {
            Mandate.ParameterNotNull(entity, "persistedEntity");

            using (NhProfilerLogging.Start(Helper.NhSession, "PerformAddOrUpdate",
                                           new OdbcParameter("entity", entity)))
            {
                // Note that it should be the caller's responsibility to add to revisions but the Cms backoffice code needs to change
                // to do that, so this is included to avoid breaking assumptions about auto-created versions until then
                if (Revisions.CanWrite)
                {
                    var newRevision = new Revision <TypedEntity>(entity);
                    Revisions.AddOrUpdate(newRevision);
                    return;
                }
                else
                {
                    if (TryUpdateExisting(entity))
                    {
                        return;
                    }

                    Helper.MapAndMerge(entity, FrameworkContext.TypeMappers);
                }
            }
        }
        public void AddOrUpdate(TypedEntity entity)
        {
            Transaction.EnsureBegun();

            // First, call Schemas.AddOrUpdate for the schema
            if (Schemas != null && Schemas.CanWrite && entity.EntitySchema != null)
            {
                Schemas.AddOrUpdate(entity.EntitySchema);
            }

            entity.Id = new HiveId((Uri)null, entity.Id.ProviderId, entity.Id.Value);

            if (Revisions.CanWrite)
            {
                var newRevision = new Revision <TypedEntity>(entity);
                Revisions.AddOrUpdate(newRevision);
                OnAddOrUpdateComplete(entity);
                return;
            }
            else
            {
                PerformAddOrUpdate(entity);
                OnAddOrUpdateComplete(entity);
            }

            AddCacheFlushesToTransaction(entity.Id);
        }
예제 #3
0
 protected override void PerformAddOrUpdate(TypedEntity entity)
 {
     // Note that it should be the caller's responsibility to add to revisions but the Cms backoffice code needs to change
     // to do that, so this is included to avoid breaking assumptions about auto-created versions until then
     if (Revisions.CanWrite)
     {
         var newRevision = new Revision <TypedEntity>(entity);
         Revisions.AddOrUpdate(newRevision);
         return;
     }
     else
     {
         Helper.PerformAddOrUpdate(entity, ExamineTransaction);
     }
 }