internal static void DeleteEntity <TEntity>(TEntity entity, NodeReference node, Connection connection)
        {
            try
            {
                connection.StartTransaction();

                node.AcquireLock(NodeReference.EXCLUSIVE_LOCK,
                                 NodeReference.LOCK_INCREMENTALLY,
                                 NodeReference.RELEASE_AT_TRANSACTION_END);

                var key = PrimaryKeyCalculator.GetPrimaryKey(entity);

                if (!IsKeyExists(key, node))
                {
                    throw new GlobalsDbException("Unable to delete entity. Entity with this primary key does not exist");
                }

                node.SetSubscriptCount(0);

                node.AppendSubscript(key);

                node.Kill();

                connection.Commit();
            }
            catch
            {
                connection.Rollback();
                throw;
            }
        }
        internal static void InsertEntity <TEntity>(TEntity entity, NodeReference node, Connection connection)
        {
            try
            {
                connection.StartTransaction();

                node.AcquireLock(NodeReference.EXCLUSIVE_LOCK,
                                 NodeReference.LOCK_INCREMENTALLY,
                                 NodeReference.RELEASE_AT_TRANSACTION_END);

                AppendPrimaryKey(entity, node);

                WriteItem(entity, node);

                connection.Commit();
            }
            catch
            {
                connection.Rollback();
                throw;
            }
        }