public void ExecuteReader_is_traced(CommandBehavior commandBehavior) { var customers = new List <Customer>(); using (var command = new TraceDbCommand(_conn.CreateCommand(), _root)) { command.CommandText = "SELECT * FROM Customers"; command.CommandType = CommandType.Text; using (var reader = command.ExecuteReader(commandBehavior)) { while (reader.Read()) { customers.Add(new Customer(reader)); } } } customers.Count.Should().Be(2); _root.Spans[1].Name.Should().Be("sql." + nameof(IDbCommand.ExecuteReader)); _root.Spans[1].Service.Should().Be("sql"); _root.Spans[1].Resource.Should().Be("main"); _root.Spans[1].Type.Should().Be("sql"); _root.Spans[1].Error.Should().Be(0); _root.Spans[1].Meta["sql.CommandBehavior"].Should().Be(commandBehavior.ToString("x")); _root.Spans[1].Meta["sql.CommandText"].Should().Be("SELECT * FROM Customers"); _root.Spans[1].Meta["sql.CommandType"].Should().Be("Text"); }
public IDataReader ExecuteReader(CommandBehavior behavior) { const string name = "sql." + nameof(ExecuteReader); var span = _spanSource.Begin(name, ServiceName, _command.Connection.Database, ServiceName); try { if (span != null) { const string metaKey = "sql." + nameof(CommandBehavior); span.SetMeta(metaKey, behavior.ToString("x")); SetMeta(span); } return(_command.ExecuteReader(behavior)); } catch (Exception ex) { span?.SetError(ex); throw; } finally { span?.Dispose(); } }
/// <summary> /// 执行并返回 DbDataReader /// </summary> /// <param name="behavior">System.Data.CommandBehavior 值之一。</param> /// <returns>DbDataReader</returns> public DbDataReader ExecuteReader(CommandBehavior behavior) { DbCommand command = null; try { command = this.GetCommand(); this.Open(); var result = command.ExecuteReader(behavior); this.OnLog("-- ExecuteReader " + behavior.ToString()); return(new AfxDataReader(this, result, command)); } catch (Exception ex) { this.Close(); throw ex; } }
internal static ArgumentOutOfRangeException NotSupportedCommandBehavior(CommandBehavior value, string method) { return(NotSupportedEnumerationValue(typeof(CommandBehavior), value.ToString(), method)); }
internal static ArgumentOutOfRangeException InvalidCommandBehavior(CommandBehavior value) { Debug.Assert((0 > (int)value) || ((int)value > 0x3F), "valid CommandType " + value.ToString()); return(InvalidEnumerationValue(typeof(CommandBehavior), (int)value)); }
public IDataReader ExecuteReader(CommandBehavior behavior) { return(new JsonDataReader(_restClient.ExecuteRequest(_commandText, behavior.ToString(), _parameters))); }
internal static ArgumentOutOfRangeException NotSupportedCommandBehavior(CommandBehavior value, string method) { return NotSupportedEnumerationValue(typeof(CommandBehavior), value.ToString(), method); }