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); } }