Interface IDatabaseAdapter
Database adapter basic interface
Inherited Members
Namespace: XData.Database.Adapter
Assembly: XData.docfx.dll
Syntax
public interface IDatabaseAdapter : IDisposable
Properties
| Improve this Doc View SourceConnectType
Database connection type
Declaration
string ConnectType { get; }
Property Value
Type | Description |
---|---|
String |
NotSupported
Dialect options not supported by adapter
Declaration
DialectOptions NotSupported { get; }
Property Value
Type | Description |
---|---|
DialectOptions |
Methods
| Improve this Doc View SourceBeginTransaction(Guid, Boolean, IsolationLevel)
Begin transaction
Declaration
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 | Success flag |
Exceptions
Type | Condition |
---|---|
XDataSqlException | SQL exceptions while beginning transaction. |
Call(Guid, StoredProcedure, CancellationToken)
Execute SQL stored procedure
Declaration
CallResult Call(Guid layer, StoredProcedure procedure, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
Guid | layer | Layer |
StoredProcedure | procedure | Procedure |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
CallResult | Call result |
Exceptions
Type | Condition |
---|---|
XDataSqlException | wrong SQL stored procedure |
Close(Guid)
Close database adapter
Declaration
void Close(Guid layer)
Parameters
Type | Name | Description |
---|---|---|
Guid | layer | Layer |
Exceptions
Type | Condition |
---|---|
XDataSqlException | SQL exceptions while closing connection |
Commit(Guid, String)
Commit transaction
Declaration
bool Commit(Guid layer, string transactionId)
Parameters
Type | Name | Description |
---|---|---|
Guid | layer | Layer |
String | transactionId | Transaction id |
Returns
Type | Description |
---|---|
Boolean | Success flag |
ExecuteNonQuery(Guid, Enum, Object[])
Execute SQL statement
Declaration
QueryResult ExecuteNonQuery(Guid layer, Enum queryIndex, params object[] paramValues)
Parameters
Type | Name | Description |
---|---|---|
Guid | layer | Layer |
Enum | queryIndex | Predefined query index |
Object[] | paramValues | Query parameters |
Returns
Type | Description |
---|---|
QueryResult | Query result |
Exceptions
Type | Condition |
---|---|
XDataSqlException | wrong SQL query parameters |
ExecuteNonQuery(Guid, Query)
Execute SQL statement
Declaration
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 |
ExecuteScalar(Guid, Enum, Object[])
Retrieve scalar value
Declaration
object ExecuteScalar(Guid layer, Enum queryIndex, params object[] paramValues)
Parameters
Type | Name | Description |
---|---|---|
Guid | layer | Layer |
Enum | queryIndex | Predefined query index |
Object[] | paramValues | Query parameters |
Returns
Type | Description |
---|---|
Object | Object |
Exceptions
Type | Condition |
---|---|
XDataSqlException | wrong SQL query parameters |
ExecuteScalar(Guid, Query)
Retrieve scalar value
Declaration
object ExecuteScalar(Guid layer, Query query)
Parameters
Type | Name | Description |
---|---|---|
Guid | layer | Layer |
Query | query | Query |
Returns
Type | Description |
---|---|
Object | Object |
Exceptions
Type | Condition |
---|---|
XDataSqlException | wrong SQL query |
FillTable(Guid, Enum, CommandBehavior, Object[])
Fill data table
Declaration
DataTable FillTable(Guid layer, Enum queryIndex, CommandBehavior behavior, params object[] paramValues)
Parameters
Type | Name | Description |
---|---|---|
Guid | layer | Layer |
Enum | queryIndex | Predefined query index |
CommandBehavior | behavior | Command behavior |
Object[] | paramValues | Query parameters |
Returns
Type | Description |
---|---|
DataTable | Data table |
Exceptions
Type | Condition |
---|---|
XDataSqlException | wrong SQL query parameters |
FillTable(Guid, Enum, Object[])
Fill data table
Declaration
DataTable FillTable(Guid layer, Enum queryIndex, params object[] paramValues)
Parameters
Type | Name | Description |
---|---|---|
Guid | layer | Layer |
Enum | queryIndex | Predefined query index |
Object[] | paramValues | Query parameters |
Returns
Type | Description |
---|---|
DataTable | Data table |
Exceptions
Type | Condition |
---|---|
XDataSqlException | wrong SQL query parameters |
FillTable(Guid, Query, CancellationToken, CommandBehavior)
Fill data table
Declaration
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 | Data table |
Exceptions
Type | Condition |
---|---|
XDataSqlException | wrong SQL query |
GetParameterValue(QueryParam)
Read parameter value
Declaration
object GetParameterValue(QueryParam parameter)
Parameters
Type | Name | Description |
---|---|---|
QueryParam | parameter | Parameter |
Returns
Type | Description |
---|---|
Object | Parameter value |
GetParameterValue<T>(QueryParam)
Read parameter value
Declaration
T GetParameterValue<T>(QueryParam parameter)
Parameters
Type | Name | Description |
---|---|---|
QueryParam | parameter | Parameter |
Returns
Type | Description |
---|---|
T | Parameter value |
Type Parameters
Name | Description |
---|---|
T |
GetTableFieldInfo(Guid, String)
Returns table structure
Declaration
ReadOnlyCollection<FieldInfo> GetTableFieldInfo(Guid layer, string table)
Parameters
Type | Name | Description |
---|---|---|
Guid | layer | Layer |
String | table | Table name |
Returns
Type | Description |
---|---|
ReadOnlyCollection<FieldInfo> | List of fields |
GetTablesInfo(Guid)
Returns table list
Declaration
ReadOnlyCollection<TableInfo> GetTablesInfo(Guid layer)
Parameters
Type | Name | Description |
---|---|---|
Guid | layer | Layer |
Returns
Type | Description |
---|---|
ReadOnlyCollection<TableInfo> | List of table |
Init(ISqlBuilder, String, String, IConfiguration)
Initialization routine
Declaration
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 | Connection string |
IConfiguration | config | Adapter configuration |
InTransaction(Guid)
Transaction context flag
Declaration
bool InTransaction(Guid layer)
Parameters
Type | Name | Description |
---|---|---|
Guid | layer | Layer |
Returns
Type | Description |
---|---|
Boolean |
IsOpen(Guid)
Check adapter connection is open
Declaration
bool IsOpen(Guid layer)
Parameters
Type | Name | Description |
---|---|---|
Guid | layer | Layer |
Returns
Type | Description |
---|---|
Boolean |
Rollback(Guid, String)
Rollback transaction
Declaration
bool Rollback(Guid layer, string transactionId)
Parameters
Type | Name | Description |
---|---|---|
Guid | layer | Layer |
String | transactionId | Transaction id |
Returns
Type | Description |
---|---|
Boolean | Success flag |
SafeConvert<T>(Object)
Safe convert data
Declaration
T SafeConvert<T>(object data)
Parameters
Type | Name | Description |
---|---|---|
Object | data | Data to convert |
Returns
Type | Description |
---|---|
T | Converted data |
Type Parameters
Name | Description |
---|---|
T | Result type |
SelectParameterValue<T>(QueryParam)
Iterate user data type (UDT) valued table/array parameter value
Declaration
IEnumerable<T> SelectParameterValue<T>(QueryParam parameter)
Parameters
Type | Name | Description |
---|---|---|
QueryParam | parameter | Parameter |
Returns
Type | Description |
---|---|
IEnumerable<T> | Parameter value |
Type Parameters
Name | Description |
---|---|
T |
Test(Guid, Query)
Test query
Declaration
void Test(Guid layer, Query query)
Parameters
Type | Name | Description |
---|---|---|
Guid | layer | Layer |
Query | query | Query |