DataStatementOptions Class
Definition
Configuration options for DataStatement.
public class DataStatementOptions : IValidatableParameterObject, IParameterObject
- Inheritance
-
DataStatementOptions
- Implements
Examples
DataStatementOptions provides configuration for DataStatement instances including command type, timeout, and parameters. This example creates a text command option with a 30-second timeout and prints its CommandType and timeout values, then creates a stored procedure option with a 5-minute timeout and an empty IDataParameter array. After configuration, ValidateOptions() is called to confirm the stored procedure settings are valid. Console output displays the command type, timeout in seconds, and validation status.
using System;
using System.Data;
using Cuemon.Data;
namespace MyApp.Data
{
public class DataStatementOptionsExample
{
public void Demonstrate()
{
// Create options for a text command with default timeout (90 seconds)
var options = new DataStatementOptions
{
Type = CommandType.Text,
Timeout = TimeSpan.FromSeconds(30)
};
Console.WriteLine($"Command type: {options.Type}");
Console.WriteLine($"Timeout: {options.Timeout.TotalSeconds} seconds");
Console.WriteLine($"Default timeout: {DataStatementOptions.DefaultTimeout.TotalSeconds} seconds");
// Configure for a stored procedure
var spOptions = new DataStatementOptions
{
Type = CommandType.StoredProcedure,
Timeout = TimeSpan.FromMinutes(5),
Parameters = Array.Empty<IDataParameter>()
};
// Validate that parameters is not null
spOptions.ValidateOptions();
Console.WriteLine("Stored procedure options are valid.");
}}
}
Constructors
| Name | Description |
|---|---|
| DataStatementOptions() | Initializes a new instance of the DataStatementOptions class. |
Properties
| Name | Description |
|---|---|
| DefaultTimeout | Gets or sets the default wait time before terminating the attempt to execute a command and generating an error. |
| Parameters | Gets or sets the parameters to use in the command. |
| Timeout | Gets or sets the wait time before terminating the attempt to execute a command and generating an error. |
| Type | Gets the command type value to execute. |
Methods
| Name | Description |
|---|---|
| ValidateOptions() | Determines whether the public read-write properties of this instance are in a valid state. |