Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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 ) );
            }
        }