Table of Contents

DataManagerOptions Class

Definition

Namespace
Cuemon.Data
Assemblies
Cuemon.Data.dll
Source
src/Cuemon.Data/DataManagerOptions.cs

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

Name Description
DataManagerOptions()

Initializes a new instance of the DataManagerOptions class.

Properties

Name Description
ConnectionString

Gets or sets the string used to open a database connection.

LeaveCommandOpen

Gets or sets a value indicating whether an IDbCommand should bypass the mechanism for releasing unmanaged resources. Default is false.

LeaveConnectionOpen

Gets or sets a value indicating whether an IDbConnection should bypass the mechanism for releasing unmanaged resources. Default is false.

PreferredReaderBehavior

Gets or sets a bitwise combination of the enumeration values that specify the preferred CommandBehavior for IDataReader operations.

Methods

Name Description
ValidateOptions()

Determines whether the public read-write properties of this instance are in a valid state.