DataSource Class
From System.Data.Generic
System.Data.Generic
| DataSource Class |
Enables easy data access to SQL server.
Namespace: System.Data.Generic
Assembly: System.Data.Generic (in System.Data.Generic.dll) Version: 1.9.5473.30542 (1.9.5473.2392)
The DataSource type exposes the following members.
| Name | Description | |
|---|---|---|
| DataSource(String) |
Returns a new instance of the DataSource class, and opens the connection immediately.
| |
| DataSource(String, Boolean) |
Returns a new instance of the DataSource class.
| |
| DataSource(ConnectionStringBuilder, Boolean) |
Returns a new instance of the DataSource class, using a connectionstring builder.
|
| Name | Description | |
|---|---|---|
| ClearPool |
Empties the connection pool associated with the current connection.
| |
| ClearPools |
Empties all connection pool(s).
| |
| Close | Obsolete.
Close the data connection.
| |
| CommitTransaction | Obsolete.
Commits a transaction from the specified context.
| |
| CreateTransaction |
Create a new transaction context.
| |
| CreateTransaction(String) |
Create a new transaction context and leaves the connection open.
| |
| Dispose |
Releases all resources used by the Component.
| |
| Equals | (Inherited from Object.) | |
| EscapeSql(String) |
Escapes standard SQL characters.
| |
| EscapeSql(String, Object) | Obsolete.
Escapes standard SQL characters. Can be used as String.Format.
| |
| ExecuteCallBack |
Executes the query, and raises a callback of ItemCallBackDelegate for each item it iterates.
| |
| ExecuteDataSet |
Executes the SQL query and returns a DataSet.
| |
| ExecuteDataTable |
Sends the SQL Query to the Connection and returns a DataTable.
| |
| ExecuteDictionary |
Executes the SQL statement and returns a dictionary of the first row. Keys in the dictionary are field names and values associated.
| |
| ExecuteListT |
Executes the query, and returns a collection of the first column.
| |
| ExecuteNObjectsT |
Executes the query, and returns a collection of object by the type T; hieratically compounded by the provided SQL JOIN and realted classes.
| |
| ExecuteNoReturn(String) |
Executes the Query against the datasource without returning any value.
| |
| ExecuteNoReturn(String, TransactionContext) |
Executes the Query against the datasource without returning any value. Supports transactions.
| |
| ExecuteObjectT |
Executes the query, and returns a object by the type T.
| |
| ExecuteObjectsT |
Executes the query, and returns a collection of object by the type T.
| |
| ExecuteReader |
Sends the SQL Query to the Connection and builds a SqlDataReader.
| |
| ExecuteScalar(String) |
Executes the query, and returns the first column of the first row in the result set returned by the query.
| |
| ExecuteScalarT(String) |
Executes the query, and returns the first column of the first row in the result set returned by the query.
| |
| ExecuteScalarT(String, T) |
Executes the query, and returns the first column of the first row in the result set returned by the query.
| |
| ExecuteScalarT(String, TransactionContext, T) |
Executes the query, and returns the first column of the first row in the result set returned by the query. Supports transactions.
| |
| ExecuteXmlReader |
Executes the Query against the datasource and returns a XML reader.
| |
| GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| Open | Obsolete.
Open the data connection.
| |
| PrepareSql |
Formats a SQL statement based on the data type of the parameters parameters.
| |
| RollbackTransaction | Obsolete.
Rolls back a transaction from the specified context.
| |
| ToString | Returns a string that represents the current object. (Inherited from Object.) |
| Name | Description | |
|---|---|---|
| ConnectionState | Obsolete.
Returns the connection state of the data connection.
| |
| ConnectionString |
Returns the connection string of the current data connection.
| |
| Current |
Returns a new instance of the DataSource class using the connection string, specific in the app.config.
| |
| SerializationSettings |
Returns the settings for serialization.
|
Enables global data access by editing web.config, app.config or the Azure configuration file, and adding GlobalDataSource to the appSettings configuration elements.
<appSettings><add key="GlobalDataSource" value="Server=.\SQLExpress;Database=somedatabase;" /></appSettings>
DataSource source = DataSource.Current();
DataSource.Current.ExecuteNoReturn("select * from table");DataSource source = new DataSource("Server=.\SQLExpress;Database=somedatabase;"); source.ExecuteNoReturn("select * from table");