Esempio n. 1
0
        public void Save(T entity)
        {
            if (!isStarted)
            {
                throw new InvalidOperationException("batch is not started");
            }
            if (isFinished)
            {
                throw new InvalidOperationException("batch is finished");
            }
            if (isCancelled)
            {
                throw new InvalidOperationException("batch is cancelled");
            }

            if (entity == null)
            {
                return;
            }

            var id = cache.GetId(entity);

            if (id > 0)
            {
                database.SaveEntity(this, id, entity);
            }
            else
            {
                id = database.CreateEntity(this, entity);
                cache.Add(id, entity);
            }

            SynchronizeLinks(entity, id);
            SynchronizeTags(entity, id);
        }