Beispiel #1
0
        private void UpsertEntity <TEntity>(TableInfo tableInfo, TEntity entity)
            where TEntity : class
        {
            if (tableInfo.IsPrimaryKeySet(entity))
            {
                // update:
                var updateAction =
                    new UpdateAction <TEntity>(this._metadataStore, entity,
                                               this._hydrator, this._connection,
                                               this._dialect, this._environment);

                Action proceed = () => updateAction.Update(entity);

                var invocation = new DataInvocation(this, this._metadataStore,
                                                    entity, proceed);

                _interceptorPipeline.ExecuteOnUpdate(invocation);
            }
            else
            {
                // insert:
                var insertAction =
                    new InsertAction <TEntity>(this._metadataStore, entity,
                                               this._hydrator, this._connection,
                                               this._dialect, this._environment);

                Action proceed = () => insertAction.Insert(entity);


                var invocation = new DataInvocation(this, this._metadataStore,
                                                    entity, proceed);

                _interceptorPipeline.ExecuteOnInsert(invocation);
            }
        }
Beispiel #2
0
        private void DeleteIntenal <TEntity>(TEntity entity) where TEntity : class
        {
            this._metadataStore.AddEntity(typeof(TEntity));
            var tableInfo = this._metadataStore.GetTableInfo <TEntity>();

            var deleteAction = new DeleteAction <TEntity>(this._metadataStore,
                                                          entity, this._connection, this._dialect, this._environment);

            Action proceed = () => deleteAction.Delete(entity);

            var invocation = new DataInvocation(this, this._metadataStore,
                                                entity, proceed);

            _interceptorPipeline.ExecuteOnDelete(invocation);

            this._sessionCache.Remove(entity, tableInfo.GetPrimaryKeyValue(entity));
        }