Show / Hide Table of Contents

    Class BaseDatabaseAdapter<TConnection, TParameter>

    Database adapter base class

    Inheritance
    Object
    BaseDatabaseAdapter<TConnection, TParameter>
    Implements
    IDatabaseAdapter
    IDisposable
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: XData.Database.Adapter
    Assembly: XData.docfx.dll
    Syntax
    [DatabaseAdapter("NONE")]
    public abstract class BaseDatabaseAdapter<TConnection, TParameter> : IDatabaseAdapter, IDisposable where TConnection : DbConnection, new()
        where TParameter : IDbDataParameter, new()
    Type Parameters
    Name Description
    TConnection
    TParameter

    Properties

    | Improve this Doc View Source

    Config

    Adapter configuration

    Declaration
    protected IConfiguration Config { get; }
    Property Value
    Type Description
    IConfiguration
    | Improve this Doc View Source

    ConnectType

    Adapter name

    Declaration
    public string ConnectType { get; }
    Property Value
    Type Description
    String
    | Improve this Doc View Source

    Context

    Database context name

    Declaration
    protected string Context { get; }
    Property Value
    Type Description
    String
    | Improve this Doc View Source

    DialectAdapter

    SQL dialect adapter instance

    Declaration
    protected ISqlBuilder DialectAdapter { get; }
    Property Value
    Type Description
    ISqlBuilder
    | Improve this Doc View Source

    Initialized

    Declaration
    protected bool Initialized { get; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    NotSupported

    Check adapter supports user defined types (UDT)

    Declaration
    public virtual DialectOptions NotSupported { get; }
    Property Value
    Type Description
    DialectOptions

    Methods

    | Improve this Doc View Source

    AddSavePoint(Guid, IDbTransaction, String)

    Add named save point

    Declaration
    protected abstract void AddSavePoint(Guid layer, IDbTransaction transaction, string savePoint)
    Parameters
    Type Name Description
    Guid layer

    Layer

    IDbTransaction transaction

    Transaction

    String savePoint

    Save point name

    | Improve this Doc View Source

    BeginTransaction(Guid, Boolean, IsolationLevel)

    Begin transaction

    Declaration
    public string BeginTransaction(Guid layer, bool read = false, IsolationLevel isolation = IsolationLevel.ReadCommitted)
    Parameters
    Type Name Description
    Guid layer

    Layer

    Boolean read

    Read only transaction flag

    IsolationLevel isolation

    Transaction isolation level

    Returns
    Type Description
    String

    Transaction key

    Exceptions
    Type Condition
    XDataSqlException

    SQL exceptions while beginning transaction.

    | Improve this Doc View Source

    Call(Guid, StoredProcedure, CancellationToken)

    Calls stored procedure

    Declaration
    public CallResult Call(Guid layer, StoredProcedure procedure, CancellationToken token)
    Parameters
    Type Name Description
    Guid layer

    Layer

    StoredProcedure procedure

    Stored procedure

    CancellationToken token

    Cancellation token

    Returns
    Type Description
    CallResult CallResult
    Exceptions
    Type Condition
    XDataSqlException
    | Improve this Doc View Source

    Close(Guid)

    Close database connection

    Declaration
    public void Close(Guid layer)
    Parameters
    Type Name Description
    Guid layer
    Exceptions
    Type Condition
    XDataSqlException

    SQL exceptions while closing connection

    | Improve this Doc View Source

    Commit(Guid, String)

    Commit transaction

    Declaration
    public bool Commit(Guid layer, string transactionId)
    Parameters
    Type Name Description
    Guid layer

    Layer

    String transactionId

    Transaction key

    Returns
    Type Description
    Boolean

    Success flag

    | Improve this Doc View Source

    CreateCommand(TConnection)

    Create specific SQL command

    Declaration
    protected virtual IDbCommand CreateCommand(TConnection connection)
    Parameters
    Type Name Description
    TConnection connection

    SQL connection

    Returns
    Type Description
    IDbCommand

    SQL command

    Remarks

    Override this when some special command parameters are required

    | Improve this Doc View Source

    CreateParameter(Guid, QueryParam)

    Create common parameter

    Declaration
    protected virtual TParameter CreateParameter(Guid layer, QueryParam parameter)
    Parameters
    Type Name Description
    Guid layer

    Layer

    QueryParam parameter

    Query parameter

    Returns
    Type Description
    TParameter

    Parameter

    | Improve this Doc View Source

    Dispose()

    IDisposable realization

    Declaration
    public void Dispose()
    | Improve this Doc View Source

    ExecuteNonQuery(Guid, Enum, Object[])

    Executes SQL expression with no result set

    Declaration
    public QueryResult ExecuteNonQuery(Guid layer, Enum queryIndex, params object[] paramValues)
    Parameters
    Type Name Description
    Guid layer

    Layer

    Enum queryIndex

    Predefined query enumeration key

    Object[] paramValues

    Query parameter values

    Returns
    Type Description
    QueryResult

    Query result

    Exceptions
    Type Condition
    XDataSqlException

    wrong SQL query parameters

    | Improve this Doc View Source

    ExecuteNonQuery(Guid, Query)

    Executes SQL expression with no result set

    Declaration
    public QueryResult ExecuteNonQuery(Guid layer, Query query)
    Parameters
    Type Name Description
    Guid layer

    Layer

    Query query

    Query

    Returns
    Type Description
    QueryResult

    Query result

    Exceptions
    Type Condition
    XDataSqlException

    wrong SQL query

    XDataConcurrencyException

    concurrency exception

    | Improve this Doc View Source

    ExecuteScalar(Guid, Enum, Object[])

    Executes scalar returning query

    Declaration
    public object ExecuteScalar(Guid layer, Enum queryIndex, params object[] paramValues)
    Parameters
    Type Name Description
    Guid layer

    Layer

    Enum queryIndex

    Predefined query enumeration key

    Object[] paramValues

    Query parameter values

    Returns
    Type Description
    Object

    Scalar value

    Exceptions
    Type Condition
    XDataSqlException

    wrong SQL query parameters

    | Improve this Doc View Source

    ExecuteScalar(Guid, Query)

    Executes scalar returning query

    Declaration
    public object ExecuteScalar(Guid layer, Query query)
    Parameters
    Type Name Description
    Guid layer

    Layer

    Query query

    Query

    Returns
    Type Description
    Object

    Reader

    Exceptions
    Type Condition
    XDataSqlException

    wrong SQL query

    XDataConcurrencyException

    concurrency exception

    | Improve this Doc View Source

    FillTable(Guid, Enum, CommandBehavior, Object[])

    Executes query and fill data table

    Declaration
    public DataTable FillTable(Guid layer, Enum queryIndex, CommandBehavior behavior, params object[] paramValues)
    Parameters
    Type Name Description
    Guid layer

    Layer

    Enum queryIndex

    Predefined query enumeration key

    CommandBehavior behavior

    Command behavior

    Object[] paramValues

    Query parameter values

    Returns
    Type Description
    DataTable

    Filled data table

    Exceptions
    Type Condition
    XDataSqlException

    wrong SQL query parameters

    | Improve this Doc View Source

    FillTable(Guid, Enum, Object[])

    Executes query and fill data table

    Declaration
    public DataTable FillTable(Guid layer, Enum queryIndex, params object[] paramValues)
    Parameters
    Type Name Description
    Guid layer

    Layer

    Enum queryIndex

    Predefined query enumeration key

    Object[] paramValues

    Query parameter values

    Returns
    Type Description
    DataTable

    Filled data table

    Exceptions
    Type Condition
    XDataSqlException

    wrong SQL query parameters

    | Improve this Doc View Source

    FillTable(Guid, Query, CancellationToken, CommandBehavior)

    Executes query and fill data table

    Declaration
    public DataTable FillTable(Guid layer, Query query, CancellationToken token, CommandBehavior behavior = CommandBehavior.Default)
    Parameters
    Type Name Description
    Guid layer

    Layer

    Query query

    Query

    CancellationToken token

    Cancellation token

    CommandBehavior behavior

    Command behavior

    Returns
    Type Description
    DataTable

    Filled data table

    Exceptions
    Type Condition
    XDataSqlException

    wrong SQL query

    | Improve this Doc View Source

    FixFieldDataType(DataRow)

    Convert field data type

    Declaration
    protected virtual Type FixFieldDataType(DataRow columnInfo)
    Parameters
    Type Name Description
    DataRow columnInfo

    Field description from schema table

    Returns
    Type Description
    Type

    Correct data type

    | Improve this Doc View Source

    GetConnection(Guid)

    Database connection

    Declaration
    protected DbConnection GetConnection(Guid layer)
    Parameters
    Type Name Description
    Guid layer
    Returns
    Type Description
    DbConnection
    | Improve this Doc View Source

    GetNativeType(DbType)

    Declaration
    protected string GetNativeType(DbType type)
    Parameters
    Type Name Description
    DbType type
    Returns
    Type Description
    String
    Exceptions
    Type Condition
    XDataAdapterException
    | Improve this Doc View Source

    GetParameterValue(QueryParam)

    Returns parameter value

    Declaration
    public object GetParameterValue(QueryParam parameter)
    Parameters
    Type Name Description
    QueryParam parameter

    Query parameter

    Returns
    Type Description
    Object

    Parameter value

    | Improve this Doc View Source

    GetParameterValue<T>(QueryParam)

    Declaration
    public T GetParameterValue<T>(QueryParam parameter)
    Parameters
    Type Name Description
    QueryParam parameter
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T
    Exceptions
    Type Condition
    XDataAdapterException
    | Improve this Doc View Source

    GetProcedureCall(ref IDbCommand, StoredProcedure, String, Boolean)

    Declaration
    protected virtual void GetProcedureCall(ref IDbCommand command, StoredProcedure procedure, string getResultName = null, bool closeCursor = false)
    Parameters
    Type Name Description
    IDbCommand command
    StoredProcedure procedure
    String getResultName
    Boolean closeCursor
    | Improve this Doc View Source

    GetSqlType(String, ref Int32, ref Int32, Int32)

    Declaration
    protected DbType GetSqlType(string typeName, ref int size, ref int scale, int precision)
    Parameters
    Type Name Description
    String typeName
    Int32 size
    Int32 scale
    Int32 precision
    Returns
    Type Description
    DbType
    Exceptions
    Type Condition
    XDataAdapterException

    Type not supported

    | Improve this Doc View Source

    GetTableFieldInfo(Guid, String)

    Declaration
    public abstract ReadOnlyCollection<FieldInfo> GetTableFieldInfo(Guid layer, string table)
    Parameters
    Type Name Description
    Guid layer
    String table
    Returns
    Type Description
    ReadOnlyCollection<FieldInfo>
    | Improve this Doc View Source

    GetTablesInfo(Guid)

    Declaration
    public abstract ReadOnlyCollection<TableInfo> GetTablesInfo(Guid layer)
    Parameters
    Type Name Description
    Guid layer
    Returns
    Type Description
    ReadOnlyCollection<TableInfo>
    | Improve this Doc View Source

    GetUtdParameter(QueryParam)

    Create and initialize user data type (UDT) parameter
    Hint: Override this method to use UDT stored procedure parameters

    Declaration
    protected virtual IDataParameter GetUtdParameter(QueryParam parameter)
    Parameters
    Type Name Description
    QueryParam parameter

    Stored procedure parameter

    Returns
    Type Description
    IDataParameter IDataParameter
    Exceptions
    Type Condition
    XDataAdapterException

    User Defined Type (UTD)

    | Improve this Doc View Source

    Init()

    Adapter initialization

    Declaration
    protected abstract void Init()
    | Improve this Doc View Source

    Init(ISqlBuilder, String, String, IConfiguration)

    Adapter initialization logic

    Declaration
    public void Init(ISqlBuilder dialectAdapter, string context, string connectionString, IConfiguration config)
    Parameters
    Type Name Description
    ISqlBuilder dialectAdapter

    SQL dialect adapter

    String context

    Context name

    String connectionString

    Database connection string

    IConfiguration config

    Adapter configuration

    | Improve this Doc View Source

    InitConnection(DbConnection)

    Declaration
    protected virtual void InitConnection(DbConnection connection)
    Parameters
    Type Name Description
    DbConnection connection
    | Improve this Doc View Source

    InTransaction(Guid)

    Connection have not committed transaction flag

    Declaration
    public bool InTransaction(Guid layer)
    Parameters
    Type Name Description
    Guid layer
    Returns
    Type Description
    Boolean
    | Improve this Doc View Source

    IsConcurrencyError(Exception)

    Check exception is a concurrency exception

    Declaration
    protected virtual bool IsConcurrencyError(Exception exception)
    Parameters
    Type Name Description
    Exception exception

    Exception

    Returns
    Type Description
    Boolean

    Exception is a concurrency exception

    | Improve this Doc View Source

    IsOpen(Guid)

    Connection is open flag

    Declaration
    public bool IsOpen(Guid layer)
    Parameters
    Type Name Description
    Guid layer
    Returns
    Type Description
    Boolean
    | Improve this Doc View Source

    ReadNativeValue<T>(String, Object)

    Read native SQL value

    Declaration
    protected virtual T ReadNativeValue<T>(string nativeSqlType, object value)
    Parameters
    Type Name Description
    String nativeSqlType

    Native SQL type name

    Object value

    Value

    Returns
    Type Description
    T

    Mapped value

    Type Parameters
    Name Description
    T

    Mapped type

    Exceptions
    Type Condition
    XDataAdapterException
    | Improve this Doc View Source

    ReadUtd<T>(Object)

    Read data from wrapped user defined type (UTD)

    Declaration
    protected virtual T ReadUtd<T>(object utdObject)
        where T : class
    Parameters
    Type Name Description
    Object utdObject

    Wrapped value

    Returns
    Type Description
    T

    Unwrapped value

    Type Parameters
    Name Description
    T

    Type mapped to user defined type (UTD)

    Exceptions
    Type Condition
    XDataAdapterException

    User Defined Type (UTD)

    | Improve this Doc View Source

    ReadUtdCollection<T>(Object)

    Read data from wrapped user defined type (UTD)

    Declaration
    protected virtual ICollection<T> ReadUtdCollection<T>(object utdCollection)
    Parameters
    Type Name Description
    Object utdCollection

    Wrapped collection

    Returns
    Type Description
    ICollection<T>

    Unwrapped collection

    Type Parameters
    Name Description
    T

    Collection element type mapped to user defined type (UTD)

    Exceptions
    Type Condition
    XDataAdapterException

    User Defined Type (UTD)

    | Improve this Doc View Source

    RegisterResultSet(String)

    Register result set parameter of stored procedure

    Declaration
    protected virtual IDbDataParameter RegisterResultSet(string resultSetName)
    Parameters
    Type Name Description
    String resultSetName

    Result set name

    Returns
    Type Description
    IDbDataParameter

    Result set parameter

    Remarks

    WARNING! Override this method to register result sets as out parameters

    Exceptions
    Type Condition
    XDataAdapterException

    RegisterResultSet

    See Also
    ResultSets
    MultipleRecordsetProceduresSupported
    RegisterRecordsetRequired
    | Improve this Doc View Source

    Rollback(Guid, String)

    Rollback transaction

    Declaration
    public bool Rollback(Guid layer, string transactionId)
    Parameters
    Type Name Description
    Guid layer

    Layer

    String transactionId

    Transaction key

    Returns
    Type Description
    Boolean

    Success flag

    | Improve this Doc View Source

    RollbackToSavePoint(Guid, IDbTransaction, String)

    Rollback to named save point

    Declaration
    protected abstract void RollbackToSavePoint(Guid layer, IDbTransaction transaction, string savePoint)
    Parameters
    Type Name Description
    Guid layer

    Layer

    IDbTransaction transaction

    Transaction

    String savePoint

    Save point name

    | Improve this Doc View Source

    SafeConvert<T>(Object)

    Safe conversion for Db specific types

    Declaration
    public virtual T SafeConvert<T>(object data)
    Parameters
    Type Name Description
    Object data

    Source data

    Returns
    Type Description
    T

    Source data converted to type

    Type Parameters
    Name Description
    T

    Result type

    Remarks

    Override this to convert some specific Db related types

    See Also
    SafeTypeConvert
    | Improve this Doc View Source

    SelectParameterValue<T>(QueryParam)

    Declaration
    public IEnumerable<T> SelectParameterValue<T>(QueryParam parameter)
    Parameters
    Type Name Description
    QueryParam parameter
    Returns
    Type Description
    IEnumerable<T>
    Type Parameters
    Name Description
    T
    Exceptions
    Type Condition
    XDataAdapterException
    | Improve this Doc View Source

    Test(Guid, Query)

    Test query syntax WARNING! Throws a error if test failed!

    Declaration
    public void Test(Guid layer, Query query)
    Parameters
    Type Name Description
    Guid layer

    Layer

    Query query

    Query

    Exceptions
    Type Condition
    XDataSqlException

    wrong SQL query

    | Improve this Doc View Source

    WrapUtd<T>(T, String)

    Wrap data to user defined type (UTD)

    Declaration
    protected virtual object WrapUtd<T>(T value, string utdTypeName)
        where T : class
    Parameters
    Type Name Description
    T value

    Value to wrap

    String utdTypeName

    User defined type name

    Returns
    Type Description
    Object

    Wrapped value

    Type Parameters
    Name Description
    T

    Type mapped to user defined type (UTD)

    Exceptions
    Type Condition
    XDataAdapterException

    User Defined Type (UTD)

    | Improve this Doc View Source

    WrapUtdCollection<T>(T[], Boolean, String, String)

    Wrap data to collection (table or array) user defined type (UTD)

    Declaration
    protected virtual object WrapUtdCollection<T>(T[] value, bool isArray, string utdTypeName, string utdElementName = null)
    Parameters
    Type Name Description
    T[] value

    Collection to wrap

    Boolean isArray

    Use VARARRAY

    String utdTypeName

    User defined type name for collection

    String utdElementName

    User defined type name for element (set to null for scalar type collection)

    Returns
    Type Description
    Object

    Wrapped collection

    Type Parameters
    Name Description
    T

    Collection element type mapped to user defined type (UTD)

    Exceptions
    Type Condition
    XDataAdapterException

    User Defined Type (UTD)

    Implements

    IDatabaseAdapter
    System.IDisposable

    Extension Methods

    SerializationExtensions.ToXml<T>(T)
    CollectionsExtensions.SetValue<TKey, T>(TKey, T)
    CollectionsExtensions.AsEnum<T>(T)
    DataObjectQueryableExtensions.CompareVariable(Object, FilterOperation, String)
    Processing.Do<T>(T, Action<IProcess<T>>[])
    TypeExtensions.TryConvert<T, TResult>(T, Func<T, TResult>)
    TypeExtensions.TryConvert<T, TResult>(T, Func<T, TResult>, TResult)
    TypeExtensions.ChangeType<T>(Object)
    TypeExtensions.ChangeType(Object, Type)
    TypeExtensions.InvokeMethod<TRet>(Object, Type[], Expression<Func<TRet>>, BindingFlags)
    TypeExtensions.InvokeMethod(Object, Type[], Expression<Action>, BindingFlags)
    TypeExtensions.InvokeMethod<TRet>(Object, Expression<Func<TRet>>, BindingFlags)
    TypeExtensions.InvokeMethod(Object, Expression<Action>, BindingFlags)
    SqlBlockExtensions.SetExpression<TTag, TResult>(TTag, Expression<Func<IBlockQueryAdapter, TResult>>)
    QueryDescriptionExtensions.SetExpression<TTag, TResult>(TTag, Expression<Func<IQueryStructureAdapter, TResult>>)
    • Improve this Doc
    • View Source
    Back to top Generated by DocFX