Table of Contents

Class DbTypeDecoratorExtensions

Namespace
Cuemon.Data
Assembly
Cuemon.Data.dll

Extension methods for the DbType enumeration hidden behind the IDecorator<T> interface.

public static class DbTypeDecoratorExtensions
Inheritance
DbTypeDecoratorExtensions

Examples

The following example demonstrates how to use the ToType extension method to resolve the equivalent System.Type for a DbType value.

using System;
using System.Data;
using Cuemon;
using Cuemon.Data;

namespace MyApp.Examples;

public class DbTypeDecoratorExtensionsExample
{
    public static void Main()
    {
        DbType[] types = { DbType.Int32, DbType.String, DbType.DateTime, DbType.Boolean };

        foreach (var dbType in types)
        {
            Type clrType = Decorator.Enclose(dbType).ToType();
            Console.WriteLine("DbType.{0} -> {1}", dbType, clrType);

        // Output:
        // DbType.Int32 -> System.Int32
        // DbType.String -> System.String
        // DbType.DateTime -> System.DateTime
        // DbType.Boolean -> System.Boolean

}}
}

Methods

ToType(IDecorator<DbType>)

Provides the equivalent Type of the underlying DbType enumeration value of the decorator.

public static Type ToType(this IDecorator<DbType> decorator)

Parameters

decorator IDecorator<DbType>

The IDecorator<T> to extend.

Returns

Type

The equivalent Type of the underlying DbType enumeration value of the decorator.

Exceptions

ArgumentNullException

decorator is null or its underlying value is null.

ArgumentOutOfRangeException

decorator underlying value is not valid.

See Also