Class DataManagerOptions
Configuration options for DataManager.
public class DataManagerOptions : IValidatableParameterObject, IParameterObject
- Inheritance
-
DataManagerOptions
- Implements
Examples
DataManagerOptions configures connection strings, reader behavior, and connection lifecycle settings for use with DataManager. This example creates an options instance with ConnectionString = "Data Source=app.db", PreferredReaderBehavior set to SequentialAccess | CloseConnection, and both LeaveConnectionOpen and LeaveCommandOpen set to false. After configuration, ValidateOptions() is called to confirm the settings are valid. Console output prints the connection string, reader behavior flag, and lifecycle settings.
using System;
using System.Data;
using Cuemon.Data;
namespace MyApp.Data
{
public sealed class DataManagerOptionsExample
{
public void Demonstrate()
{
var options = new DataManagerOptions
{
ConnectionString = "Data Source=app.db",
PreferredReaderBehavior = CommandBehavior.SequentialAccess | CommandBehavior.CloseConnection,
LeaveConnectionOpen = false,
LeaveCommandOpen = false
};
options.ValidateOptions();
Console.WriteLine($"Connection: {options.ConnectionString}");
Console.WriteLine($"Reader behavior: {options.PreferredReaderBehavior}");
Console.WriteLine($"Leave connection open: {options.LeaveConnectionOpen}");
Console.WriteLine($"Leave command open: {options.LeaveCommandOpen}");
}
}
}
Constructors
DataManagerOptions()
Initializes a new instance of the DataManagerOptions class.
public DataManagerOptions()
Remarks
The following table shows the initial property values for an instance of DataManagerOptions.
| Property | Initial Value |
|---|---|
| LeaveConnectionOpen | false |
| LeaveCommandOpen | false |
| PreferredReaderBehavior | CloseConnection |
Properties
ConnectionString
Gets or sets the string used to open a database connection.
public string ConnectionString { get; set; }
Property Value
- string
The string that includes the source database name, and other parameters needed to establish a database connection.
LeaveCommandOpen
Gets or sets a value indicating whether an IDbCommand should bypass the mechanism for releasing unmanaged resources. Default is false.
public bool LeaveCommandOpen { get; set; }
Property Value
- bool
trueif an IDbCommand should bypass the mechanism for releasing unmanaged resources; otherwise,false.
LeaveConnectionOpen
Gets or sets a value indicating whether an IDbConnection should bypass the mechanism for releasing unmanaged resources. Default is false.
public bool LeaveConnectionOpen { get; set; }
Property Value
- bool
trueif an IDbConnection should bypass the mechanism for releasing unmanaged resources; otherwise,false.
PreferredReaderBehavior
Gets or sets a bitwise combination of the enumeration values that specify the preferred CommandBehavior for IDataReader operations.
public CommandBehavior PreferredReaderBehavior { get; set; }
Property Value
- CommandBehavior
The enumeration values that specify which command behavior to apply for IDataReader operations.
Methods
ValidateOptions()
Determines whether the public read-write properties of this instance are in a valid state.
public void ValidateOptions()
Remarks
This method is expected to throw exceptions when one or more conditions fails to be in a valid state.