public void Des() { RequestContext context = new RequestContext { Scope = Scope, SqlId = "Query", Request = new { Taken = 10 } }; context.Setup(_smartSqlContext, _sqlBuilder); var dbSession = _sessionStore.CreateDbSession(DataSource); var result = _commandExecuter.ExecuteReader(dbSession, context); var deser = _deserializerFactory.Create(); var list = deser.ToEnumerable <T_Entity>(context, result).ToList(); result.Close(); result.Dispose(); }
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 ExecuteReader() { RequestContext context = new RequestContext { Scope = Scope, SqlId = "Query", //Request = new { Id = 1, UserName = "******" }, }; context.Setup(_smartSqlContext, _sqlBuilder); var dbSession = _sessionStore.CreateDbSession(DataSource); var result = _commandExecuter.ExecuteReader(dbSession, context); while (result.Read()) { var id = result.GetInt64(0); } result.Close(); result.Dispose(); }