public EntityKey Insert( BaseEntity entity )
        {
            if ( entity == null )
                throw new ArgumentNullException( "entity" );
            if ( !entity.EntityKey.IsNull )
                throw new ArgumentException( "Cannot insert an entity that has an identifier.", "entity" );

            entity.Validate();

            this.Enlist();

            entity.EntityKey = Storage.MakeEntityKey();
            BaseEntity entityClone = entity.Clone();

            this.InternalSet( entityClone );

            if ( this.redoLog != null )
            {
                this.redoLog.Add( new StorageOperation( StorageOperationKind.Insert, entityClone ) );
            }


            return entity.EntityKey;
        }
        public void Update( BaseEntity entity )
        {
            if ( entity == null )
                throw new ArgumentNullException( "entity" );
            if ( entity.EntityKey.IsNull )
                throw new ArgumentException( "Cannot update an entity that has no identifier.", "entity" );

            entity.Validate();

            this.Enlist();

            BaseEntity entityClone = entity.Clone();
            this.InternalSet( entityClone );

            if ( this.redoLog != null )
            {
                this.redoLog.Add( new StorageOperation( StorageOperationKind.Update, entityClone ) );
            }
        }