Interface IDataAccessService
Namespace: DataBaseAccess
Assembly: DataBaseAccess.dll
Syntax
public interface IDataAccessService
Properties
| Improve this Doc View SourceConnectionString
Property containing the connection string to the database.
Declaration
string ConnectionString { get; }
Property Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceCreateQueryDataTable(String, Dictionary<String, Object>, CommandType)
Creates and returns a System.Data.DataTable with the sql query string passed as parameter.
Declaration
DataTable CreateQueryDataTable(string query, Dictionary<string, object> parameters = null, CommandType commandType = CommandType.Text)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | The sql query to execute |
System.Collections.Generic.Dictionary<System.String, System.Object> | parameters | The query aditional parameters |
System.Data.CommandType | commandType | Indicates how the query string will be interpreted. The default is System.Data.CommandType.Text |
Returns
Type | Description |
---|---|
System.Data.DataTable | The created System.Data.DataTable |
NonQuery(String, Dictionary<String, Object>, CommandType)
Executes the passed sql query in the database and returns the number of rows affected. For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of rows affected by the trigger or triggers. For all other types of statements and rollbacks the return value is -1.
Declaration
int NonQuery(string query, Dictionary<string, object> parameters = null, CommandType commandType = CommandType.Text)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | The sql query to execute |
System.Collections.Generic.Dictionary<System.String, System.Object> | parameters | The query aditional parameters |
System.Data.CommandType | commandType | Indicates how the query string will be interpreted. The default is System.Data.CommandType.Text |
Returns
Type | Description |
---|---|
System.Int32 | The number of rows affected |
Query(String, Dictionary<String, Object>, CommandType)
Executes the passed sql query in the database and returns a System.Collections.Generic.List<T> of elements of type System.Collections.Generic.Dictionary<TKey, TValue>. Each element in the list represents a row and each dictionary element represents a column. The column value can be accesed by its same.
Declaration
QueryResult Query(string query, Dictionary<string, object> parameters = null, CommandType commandType = CommandType.Text)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | The sql query to execute |
System.Collections.Generic.Dictionary<System.String, System.Object> | parameters | The query aditional parameters |
System.Data.CommandType | commandType | Indicates how the query string will be interpreted. The default is System.Data.CommandType.Text |
Returns
Type | Description |
---|---|
QueryResult | A collection of rows returned by the query |
Scalar<T>(String, Dictionary<String, Object>, CommandType)
Retrieve a single value from a database. It returns the first column of the first row in the result set returned by the query, the additional columns or rows are ignored.
Declaration
T Scalar<T>(string query, Dictionary<string, object> parameters = null, CommandType commandType = CommandType.Text)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | The sql query to execute |
System.Collections.Generic.Dictionary<System.String, System.Object> | parameters | The query aditional parameters |
System.Data.CommandType | commandType | Indicates how the query string will be interpreted. The default is System.Data.CommandType.Text |
Returns
Type | Description |
---|---|
T | The first column of the first row in the result set, or a null reference if the result set is empty. |
Type Parameters
Name | Description |
---|---|
T | The expected scalar query type |