Table of Contents

Class DbCmd

Namespace
PHCDataLayer
Assembly
PHCDataLayer.dll
public class DbCmd : CloneVO, IBaseSerialization, ICloneVO, ICloneable
Inheritance
DbCmd

Fields

_commandText

protected string _commandText

Field Value

string

_connectionID

protected string _connectionID

Field Value

string

_tableName

Importantly, it serves to place the table name in the places of the sql command, which needs this reference, example "alter table ..."

protected string _tableName

Field Value

string

_transactionID

protected string _transactionID

Field Value

string

Properties

AppendDbName

public bool AppendDbName { get; set; }

Property Value

bool

CommandText

Result property CommandText of the SqlCommand executed in the database

public string CommandText { get; set; }

Property Value

string

CommandTimeout

The default value of a SQL command is 30 seconds but we use default (300 = 5 minutes) because we have some "cenas" like (fxlog)

public int CommandTimeout { get; set; }

Property Value

int

Connection

Mandatory, If not provided, the command will try to create one with the value of the ConnectionString property. defines the connection that will be used to execute the command in the database, if the connection is not open, the command will try to open with a transaction using the value of 'RequireTransaction', then when executing 'Close' the command will remember if it was he who opened the connection and in that case it will close it automatically, along with the transaction.

public DbConnection Connection { get; set; }

Property Value

DbConnection

ConnectionID

protected string ConnectionID { get; }

Property Value

string

DataBaseName

public string DataBaseName { get; set; }

Property Value

string

DataParameters

public List<SqlParameter> DataParameters { get; set; }

Property Value

List<SqlParameter>

DtReader

Result property When the ExecuteType property is equal to "Reader" then the result of the sql command is stored in this property

public SqlDataReader DtReader { get; set; }

Property Value

SqlDataReader

EndTime

public DateTime EndTime { get; set; }

Property Value

DateTime

EntityStructure

public VOStructure EntityStructure { get; set; }

Property Value

VOStructure

ErrorMsgs

Result property List of errors already translated into the language of LocaleManager

public List<string> ErrorMsgs { get; set; }

Property Value

List<string>

ExceptionMsg

Result property When the sql command is executed in the database, if an exception occurs and if there is a message, this is where it is saved

public string ExceptionMsg { get; set; }

Property Value

string

ExceptionNumber

Result property When the sql command is executed in the database, if an exception occurs and if there is a number, this is where it is saved

public int ExceptionNumber { get; set; }

Property Value

int

ExecuteType

Result property Type of sql command executed on the database

public DbCmd.ExecuteTypes ExecuteType { get; set; }

Property Value

DbCmd.ExecuteTypes

FirstRowColValue

Result property When the ExecuteType property is equal to "Scalar" then the result of the sql command is stored in this property

public object FirstRowColValue { get; set; }

Property Value

object

IgnoreErrorNumbers

When the command is executed in the database with an error, in catch although we keep that error, it is not generated in the log by "SystemController.LogManager.Log"

public List<int> IgnoreErrorNumbers { get; set; }

Property Value

List<int>

RowsAffected

Result property When the ExecuteType property is equal to "NonQuery" then the result of the sql command is stored in this property

public int RowsAffected { get; set; }

Property Value

int

StartTime

public DateTime StartTime { get; set; }

Property Value

DateTime

TableAliasName

public string TableAliasName { get; set; }

Property Value

string

TableName

public string TableName { get; set; }

Property Value

string

TargetStructure

public VOStructure TargetStructure { get; set; }

Property Value

VOStructure

TransactionID

protected string TransactionID { get; }

Property Value

string

XmlReader

Result property When the ExecuteType property is equal to "ReaderXML" then the result of the sql command is stored in this property

public XmlReader XmlReader { get; set; }

Property Value

XmlReader

Methods

AddConnectionToPool(DbConnection)

public DbConnection AddConnectionToPool(DbConnection connectionItem)

Parameters

Nome Tipo Descrição
connectionItem DbConnection

Returns

DbConnection

AddConnectionToPool(string)

public DbConnection AddConnectionToPool(string connectionString)

Parameters

Nome Tipo Descrição
connectionString string

Returns

DbConnection

Clone()

public object Clone()

Returns

object

Clone<T>(T)

public T Clone<T>(T cloneItem) where T : DbCmd

Parameters

Nome Tipo Descrição
cloneItem T

Returns

T

Type Parameters

T

Close()

public void Close()

Close(bool)

public void Close(bool operationResult)

Parameters

Nome Tipo Descrição
operationResult bool

ExecuteNonQuery()

Execute the command returned by GetCommand() with type NonQuery

public bool ExecuteNonQuery()

Returns

bool

ExecuteNonQuery(SqlCommand)

Execute the command with type NonQuery

public bool ExecuteNonQuery(SqlCommand cmd)

Parameters

Nome Tipo Descrição
cmd SqlCommand

Returns

bool

ExecuteReader(ref SqlCommand)

Execute the command with type Reader

public bool ExecuteReader(ref SqlCommand sqlCmd)

Parameters

Nome Tipo Descrição
sqlCmd SqlCommand

Returns

bool

ExecuteScalar()

public bool ExecuteScalar()

Returns

bool

ExecuteScalar(ref SqlCommand)

public bool ExecuteScalar(ref SqlCommand cmd)

Parameters

Nome Tipo Descrição
cmd SqlCommand

Returns

bool

GetCommand()

public virtual SqlCommand GetCommand()

Returns

SqlCommand

GetDataBaseName()

protected string GetDataBaseName()

Returns

string

GetNativeConnectionString()

public string GetNativeConnectionString()

Returns

string

GetPath(string, string)

protected string GetPath(string table_name, string database_name)

Parameters

Nome Tipo Descrição
table_name string
database_name string

Returns

string

GetRawEntityStructure()

public VOStructure GetRawEntityStructure()

Returns

VOStructure

GetTablePath()

protected string GetTablePath()

Returns

string

GetTablePath(string, string)

protected string GetTablePath(string _tableName, string _databaseName)

Parameters

Nome Tipo Descrição
_tableName string
_databaseName string

Returns

string

IsReadOnlyDB()

public virtual bool IsReadOnlyDB()

Returns

bool

OnGetTablePath(ref string)

protected void OnGetTablePath(ref string _tableName)

Parameters

Nome Tipo Descrição
_tableName string

Open()

Open the connection to the database

public bool Open()

Returns

bool

Parse()

public virtual string Parse()

Returns

string

PrepareConnection()

public void PrepareConnection()

RequireTransaction()

public virtual bool RequireTransaction()

Returns

bool

SetConnection()

public virtual void SetConnection()