• DataStax Enterprise C# Driver API Documentation

    Show / Hide Table of Contents
    • Dse
      • AggregateMetadata
      • AlreadyExistsException
      • AtomicMonotonicTimestampGenerator
      • AtomicMonotonicWinApiTimestampGenerator
      • AuthenticationException
      • BatchStatement
      • BatchType
      • BigIntegerTypeAdapter
      • BoundStatement
      • Builder
      • BusyPoolException
      • CassandraConnectionStringBuilder
      • ClientOptions
      • Cluster
      • ColumnDesc
      • ColumnTypeCode
      • CompressionType
      • Configuration
      • ConsistencyLevel
      • ConstantReconnectionPolicy
      • ConstantSpeculativeExecutionPolicy
      • CqlColumn
      • CustomColumnInfo
      • DataCollectionMetadata
      • DataCollectionMetadata.SortOrder
      • DCAwareRoundRobinPolicy
      • DecimalTypeAdapter
      • DefaultRetryPolicy
      • Diagnostics
      • DowngradingConsistencyRetryPolicy
      • DriverException
      • DriverInternalError
      • DseCluster
      • DseClusterBuilder
      • DseConfiguration
      • DseLoadBalancingPolicy
      • Duration
      • DynamicCompositeTypeAdapter
      • EC2MultiRegionTranslator
      • ExecutionException
      • ExecutionInfo
      • ExponentialReconnectionPolicy
      • Extensions
      • FallthroughRetryPolicy
      • FixedReconnectionPolicy
      • FunctionFailureException
      • FunctionMetadata
      • Host
      • HostDistance
      • HostsEventArgs
      • HostsEventArgs.Kind
      • HostsEventHandler
      • IAddressTranslator
      • IAuthenticator
      • IAuthProvider
      • IAuthProviderNamed
      • ICluster
      • IColumnInfo
      • IdempotenceAwareRetryPolicy
      • IDseCluster
      • IDseSession
      • IExecutionProfile
      • IExecutionProfileBuilder
      • IExecutionProfileOptions
      • IExtendedRetryPolicy
      • IFrameCompressor
      • IInitializer
      • ILoadBalancingPolicy
      • IndexMetadata
      • IndexMetadata.IndexKind
      • InvalidConfigurationInQueryException
      • InvalidQueryException
      • InvalidTypeException
      • IReconnectionPolicy
      • IReconnectionSchedule
      • IRetryPolicy
      • IsBootstrappingException
      • ISession
      • ISessionState
      • ISpeculativeExecutionPlan
      • ISpeculativeExecutionPolicy
      • IStatement
      • ITimestampGenerator
      • ITypeAdapter
      • KeyspaceMetadata
      • KeyType
      • ListColumnInfo
      • LocalDate
      • LocalTime
      • Logger
      • LoggingRetryPolicy
      • MapColumnInfo
      • MaterializedViewMetadata
      • Metadata
      • MetadataSyncOptions
      • MetricsExtensions
      • MonitorReportingOptions
      • NoHostAvailableException
      • NoneAuthProvider
      • NoSpeculativeExecutionPolicy
      • NullTypeAdapter
      • OperationTimedOutException
      • OverloadedException
      • PlainTextAuthProvider
      • Policies
      • PoolingOptions
      • PreparedQueryNotFoundException
      • PreparedStatement
      • PreparedStatementIdMismatchException
      • ProtocolErrorException
      • ProtocolOptions
      • ProtocolVersion
      • QueryExecutionException
      • QueryOptions
      • QueryProtocolOptions
      • QueryProtocolOptions.QueryFlags
      • QueryTimeoutException
      • QueryTrace
      • QueryTrace.Event
      • QueryValidationException
      • ReadFailureException
      • ReadTimeoutException
      • RegularStatement
      • ReplicationStrategies
      • RequestInvalidException
      • RetryDecision
      • RetryDecision.RetryDecisionType
      • RetryLoadBalancingPolicy
      • RetryLoadBalancingPolicyEventArgs
      • RoundRobinPolicy
      • RoutingKey
      • Row
      • RowSet
      • RowSetMetadata
      • SchemaChangedEventArgs
      • SchemaChangedEventArgs.Kind
      • SchemaChangedEventHandler
      • ServerErrorException
      • Session
      • SetColumnInfo
      • SimpleStatement
      • SocketOptions
      • SSLOptions
      • Statement
      • SyntaxError
      • TableColumn
      • TableMetadata
      • TableOptions
      • TimeUuid
      • TokenAwarePolicy
      • ToManyConnectionsPerHost
      • TraceRetrievalException
      • TruncateException
      • TupleColumnInfo
      • TypeAdapters
      • UdtColumnInfo
      • UdtMap
      • UdtMap<T>
      • UdtMappingDefinitions
      • UnauthorizedException
      • UnavailableException
      • Unset
      • WriteFailureException
      • WriteTimeoutException
    • Dse.AppMetrics
      • DriverAppMetricsOptions
    • Dse.AppMetrics.MetricTypes
      • IAppMetricsCounter
      • IAppMetricsGauge
      • IAppMetricsMeter
      • IAppMetricsMetric
      • IAppMetricsTimer
    • Dse.AppMetrics.MetricValues
      • IAppMetricsHistogramValue
      • IAppMetricsMeterValue
      • IAppMetricsMetricWithValue<T>
      • IAppMetricsTimerValue
    • Dse.Auth
      • DseGssapiAuthProvider
      • DsePlainTextAuthProvider
    • Dse.Auth.Sspi
      • SspiException
    • Dse.Data
      • CqlBatchTransaction
      • CqlCommand
      • CqlConnection
      • CqlDataAdapter
      • CqlParameter
      • CqlParameterCollection
      • CqlProviderFactory
      • CqlReader
    • Dse.Data.Linq
      • AllowFilteringAttribute
      • Batch
      • ClusteringKeyAttribute
      • ColumnAttribute
      • CompactStorageAttribute
      • CounterAttribute
      • CqlArgumentException
      • CqlCommand
      • CqlConditionalCommand<TEntity>
      • CqlDelete
      • CqlFunction
      • CqlInsert<TEntity>
      • CqlLinqNotSupportedException
      • CqlOperator
      • CqlQuery<TEntity>
      • CqlQueryBase<TEntity>
      • CqlQueryExtensions
      • CqlQuerySingleElement<TEntity>
      • CqlScalar<TEntity>
      • CqlToken
      • CqlUpdate
      • IgnoreAttribute
      • ITable
      • PartitionKeyAttribute
      • SecondaryIndexAttribute
      • SessionExtensions
      • StaticColumnAttribute
      • Table<TEntity>
      • TableAttribute
      • TableType
    • Dse.Geometry
      • GeometryBase
      • LineString
      • Point
      • Polygon
    • Dse.Graph
      • Edge
      • Element
      • GraphNode
      • GraphOptions
      • GraphResultSet
      • GraphStatement
      • IEdge
      • IElement
      • IGraphNode
      • IGraphStatement
      • IPath
      • IProperty
      • IVertex
      • IVertexProperty
      • Path
      • SimpleGraphStatement
      • Vertex
    • Dse.Mapping
      • AppliedInfo<T>
      • ColumnMap
      • Cql
      • CqlQueryOptions
      • IColumnDefinition
      • ICqlBatch
      • ICqlQueryAsyncClient
      • ICqlQueryClient
      • ICqlWriteAsyncClient
      • ICqlWriteClient
      • IMapper
      • IPage<T>
      • ITypeDefinition
      • Map<TPoco>
      • Mapper
      • MappingConfiguration
      • Mappings
      • SortOrder
    • Dse.Mapping.Attributes
      • ClusteringKeyAttribute
      • ColumnAttribute
      • CounterAttribute
      • FrozenAttribute
      • FrozenKeyAttribute
      • FrozenValueAttribute
      • IgnoreAttribute
      • PartitionKeyAttribute
      • SecondaryIndexAttribute
      • StaticColumnAttribute
      • TableAttribute
    • Dse.Mapping.TypeConversion
      • DefaultTypeConverter
      • EnumStringMapper<T>
      • NullableEnumStringMapper<T>
      • TypeConverter
    • Dse.Mapping.Utils
      • MemberInfoExtensions
    • Dse.Metrics
      • DriverMetricsOptions
      • IDriverMetrics
      • IMetric
      • IMetricsRegistry<TMetric>
      • NodeMetric
      • NodeMetric.Counters
      • NodeMetric.Gauges
      • NodeMetric.Meters
      • NodeMetric.Timers
      • SessionMetric
      • SessionMetric.Counters
      • SessionMetric.Gauges
      • SessionMetric.Meters
      • SessionMetric.Timers
    • Dse.Metrics.Abstractions
      • IDriverCounter
      • IDriverGauge
      • IDriverMeter
      • IDriverMetric
      • IDriverMetricsProvider
      • IDriverTimer
    • Dse.Search
      • DateRange
      • DateRangeBound
      • DateRangePrecision
    • Dse.Serialization
      • CustomTypeSerializer<T>
      • TypeSerializer
      • TypeSerializer<T>
      • TypeSerializerDefinitions
      • UdtSerializer

    Class PreparedStatement

    Represents a prepared statement, a query with bound variables that has been prepared (pre-parsed) by the database.

    A prepared statement can be executed once concrete values has been provided for the bound variables. The pair of a prepared statement and values for its bound variables is a BoundStatement and can be executed (by Session#Execute).

    Inheritance
    System.Object
    PreparedStatement
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Dse
    Assembly: Dse.dll
    Syntax
    public class PreparedStatement

    Constructors

    PreparedStatement()

    Initializes a new instance of the Cassandra.PreparedStatement class

    Declaration
    public PreparedStatement()

    Properties

    ConsistencyLevel

    Gets the default consistency level for all executions using this instance

    Declaration
    public ConsistencyLevel? ConsistencyLevel { get; }
    Property Value
    Type Description
    System.Nullable<ConsistencyLevel>

    IncomingPayload

    Gets the the incoming payload, that is, the payload that the server sent back with its prepared response, or null if the server did not include any custom payload.

    Declaration
    public IDictionary<string, byte[]> IncomingPayload { get; }
    Property Value
    Type Description
    System.Collections.Generic.IDictionary<System.String, System.Byte[]>

    IsIdempotent

    Determines if the query is idempotent, i.e. whether it can be applied multiple times without changing the result beyond the initial application.

    Idempotence of the prepared statement plays a role in ISpeculativeExecutionPolicy. If a query is not idempotent, the driver will not schedule speculative executions for it.

    When the property is null, the driver will use the default value from the GetDefaultIdempotence().
    Declaration
    public bool? IsIdempotent { get; }
    Property Value
    Type Description
    System.Nullable<System.Boolean>

    OutgoingPayload

    Gets custom payload for that will be included when executing an Statement.

    Declaration
    public IDictionary<string, byte[]> OutgoingPayload { get; }
    Property Value
    Type Description
    System.Collections.Generic.IDictionary<System.String, System.Byte[]>

    RoutingIndexes

    Gets or sets the parameter indexes that are part of the partition key

    Declaration
    public int[] RoutingIndexes { get; }
    Property Value
    Type Description
    System.Int32[]

    RoutingKey

    Gets the routing key for the prepared statement.

    Declaration
    public RoutingKey RoutingKey { get; }
    Property Value
    Type Description
    RoutingKey

    Variables

    Gets metadata on the bounded variables of this prepared statement.

    Declaration
    public RowSetMetadata Variables { get; }
    Property Value
    Type Description
    RowSetMetadata

    Methods

    Bind(Object[])

    Creates a new BoundStatement instance with the provided parameter values.

    You can specify the parameter values by the position of the markers in the query, or by name using a single instance of an anonymous type, with property names as parameter names.

    Note that while no more values than bound variables can be provided, it is allowed to provide less values that there is variables.

    You can provide a comma-separated variable number of arguments to the Bind() method. When providing an array, the reference might be used by the driver making it not safe to modify its content.

    Declaration
    public virtual BoundStatement Bind(params object[] values)
    Parameters
    Type Name Description
    System.Object[] values

    The values to bind to the variables of the newly created BoundStatement.

    Returns
    Type Description
    BoundStatement

    The newly created BoundStatement with the query parameters set.

    Examples

    Binding different parameters:

    PreparedStatement ps = session.Prepare("INSERT INTO table (id, name) VALUES (?, ?)");
    BoundStatement statement = ps.Bind(Guid.NewGuid(), "Franz Ferdinand");
    session.Execute(statement);

    SetConsistencyLevel(ConsistencyLevel)

    Sets a default consistency level for all BoundStatement created from this object.

    If no consistency level is set through this method, the BoundStatement created from this object will use the default consistency level (One).

    Changing the default consistency level is not retroactive, it only applies to BoundStatement created after the change.

    Declaration
    public PreparedStatement SetConsistencyLevel(ConsistencyLevel consistency)
    Parameters
    Type Name Description
    ConsistencyLevel consistency

    the default consistency level to set.

    Returns
    Type Description
    PreparedStatement

    this PreparedStatement object.

    SetIdempotence(Boolean)

    Sets whether the prepared statement is idempotent.

    Idempotence of the query plays a role in ISpeculativeExecutionPolicy. If a query is not idempotent, the driver will not schedule speculative executions for it.

    Declaration
    public PreparedStatement SetIdempotence(bool value)
    Parameters
    Type Name Description
    System.Boolean value
    Returns
    Type Description
    PreparedStatement

    SetOutgoingPayload(IDictionary<String, Byte[]>)

    Sets a custom outgoing payload for this statement. Each time an statement generated using this prepared statement is executed, this payload will be included in the request. Once it is set using this method, the payload should not be modified.

    Declaration
    public PreparedStatement SetOutgoingPayload(IDictionary<string, byte[]> payload)
    Parameters
    Type Name Description
    System.Collections.Generic.IDictionary<System.String, System.Byte[]> payload
    Returns
    Type Description
    PreparedStatement

    SetRoutingKey(RoutingKey[])

    Set the routing key for this query.

    The routing key is a hint for token aware load balancing policies but is never mandatory. This method allows you to manually provide a routing key for this query.

    Use this method ONLY if the partition keys are the same for all query executions (hard-coded parameters).

    If the partition key is composite, you should provide multiple routing key components.

    Declaration
    public PreparedStatement SetRoutingKey(params RoutingKey[] routingKeyComponents)
    Parameters
    Type Name Description
    RoutingKey[] routingKeyComponents

    the raw (binary) values to compose to obtain the routing key.

    Returns
    Type Description
    PreparedStatement

    this PreparedStatement object.

    SetRoutingNames(String[])

    For named query markers, it sets the parameter names that are part of the routing key.

    Use this method ONLY if the parameter names are different from the partition key names.

    Declaration
    public PreparedStatement SetRoutingNames(params string[] names)
    Parameters
    Type Name Description
    System.String[] names
    Returns
    Type Description
    PreparedStatement

    this PreparedStatement object.

    Back to top © DataStax, All rights reserved.