public void Invoke <TResult>(ExecutionContext executionContext) { try { switch (executionContext.Type) { case ExecutionType.Execute: { var recordsAffected = _commandExecuter.ExecuteNonQuery(executionContext); executionContext.Result.SetData(recordsAffected); return; } case ExecutionType.ExecuteScalar: { ParseExecuteScalarDbValue <TResult>(executionContext); return; } case ExecutionType.GetDataSet: { var resultData = _commandExecuter.GetDateSet(executionContext); executionContext.Result.SetData(resultData); return; } case ExecutionType.GetDataTable: { var resultData = _commandExecuter.GetDateTable(executionContext); executionContext.Result.SetData(resultData); return; } case ExecutionType.Query: case ExecutionType.QuerySingle: { executionContext.DataReaderWrapper = _commandExecuter.ExecuteReader(executionContext); break; } default: throw new ArgumentOutOfRangeException(); } Next.Invoke <TResult>(executionContext); } finally { if (executionContext.DataReaderWrapper != null) { executionContext.DataReaderWrapper.Close(); executionContext.DataReaderWrapper.Dispose(); } } }
public void ExecuteNonQuery() { RequestContext context = new RequestContext { Scope = Scope, SqlId = "Delete", Request = new { Id = 3 } }; context.Setup(_smartSqlOptions); var dbSession = _sessionStore.CreateDbSession(DataSource); var result = _commandExecuter.ExecuteNonQuery(dbSession, context); //Assert.Equal<int>(1, result); }