C# Class Oda.Sql

This plugin allows you to attach to a T-SQL database and preserve an open connection. It also contains CRUD utilities (Create, Read, Update, Delete) for JSON to SQL and SQL to JSON.
Inheritance: Plugin
Show file Open project: CorbinDallas/Oda

Public Properties

Property Type Description
Connection System.Data.SqlClient.SqlConnection

Public Methods

Method Description
Close ( ) : void

Closes the persistent connection.

CreateConnection ( ) : SqlConnection

Creates a new Sql connection using the default connection string defined in the web.config of the current web site.

CreateConnection ( string connectionName ) : SqlConnection

Creates a new Sql connection using a named connection string defined in the web.config of the current site.

JsonReadOrDelete ( string objectName, int rowFrom, int rowTo ) : JsonResponse

Read from SQL objects and return as JSON. Uses the JsonReadOrDelete stored procedure to return limited record sets to the Sql client. Great for streaming pages of data to a stateless web client.

JsonReadOrDelete ( string query, int rowFrom, int rowTo, System.Guid accountId, SqlParameter parameters, string orderBy, OrderDirection orderByDirection ) : JsonResponse

Read from SQL objects and return as JSON. Uses the JsonReadOrDelete stored procedure to return limited record sets to the Sql client. Great for streaming pages of data to a stateless web client.

JsonReadOrDelete ( string query, int rowFrom, int rowTo, SqlParameter parameters, string orderBy, OrderDirection orderByDirection ) : JsonResponse

Read from SQL objects and return as JSON. Uses the JsonReadOrDelete stored procedure to return limited record sets to the Sql client. Great for streaming pages of data to a stateless web client.

JsonReadOrDelete ( string objectName, int rowFrom, int rowTo, SqlWhere where ) : JsonResponse

Read from SQL objects and return as JSON. Uses the JsonReadOrDelete stored procedure to return limited record sets to the Sql client. Great for streaming pages of data to a stateless web client.

JsonReadOrDelete ( string objectName, int rowFrom, int rowTo, SqlWhere whereClause, System.Guid accountId, SqlWhere searchClause, string>.IDictionary aggregates, ICollection selectedRows, bool includeSchemaData, System.Int64 checksum, bool deleteSelection, string orderBy, OrderDirection orderByDirection ) : JsonResponse

Read from SQL objects and return as JSON. Uses the JsonReadOrDelete stored procedure to return limited record sets to the Sql client. Great for streaming pages of data to a stateless web client. Note: Delete requires a [RowVersion] rowversion column present in the table. State data is stored in the table UIColumns on a per user basis. Users are defined in Oda.Authentication class and in the table Accounts.

JsonReadOrDelete ( string query, int rowFrom, int rowTo, string orderBy, OrderDirection orderByDirection ) : JsonResponse

Read from SQL objects and return as JSON. Uses the JsonReadOrDelete stored procedure to return limited record sets to the Sql client. Great for streaming pages of data to a stateless web client.

Open ( ) : void

Opens the persistent connection.

Private Methods

Method Description
ConnectionStateChange ( object sender, StateChangeEventArgs e ) : void
CreateUpdateOrDelete ( string objectName, List data, bool overwrite, System.Int64 commandType ) : object>.Dictionary
GetWebConfigSettings ( ) : void

Gets settings from the Web.Config file.

JsonReadOrDelete ( string query, int rowFrom, int rowTo, System.Guid accountId, SqlParameter parameters, string orderBy, OrderDirection orderByDirection, SqlConnection connection ) : JsonResponse
JsonReadOrDelete ( string objectName, int rowFrom, int rowTo, SqlWhere whereClause, System.Guid accountId, SqlWhere searchClause, string>.IDictionary aggregates, ICollection selectedRows, bool includeSchemaData, System.Int64 checksum, bool deleteSelection, string orderBy, OrderDirection orderByDirection, SqlConnection connection ) : JsonResponse
Sql ( ) : System

Method Details

Close() public static method

Closes the persistent connection.
public static Close ( ) : void
return void

CreateConnection() public static method

Creates a new Sql connection using the default connection string defined in the web.config of the current web site.
public static CreateConnection ( ) : SqlConnection
return System.Data.SqlClient.SqlConnection

CreateConnection() public static method

Creates a new Sql connection using a named connection string defined in the web.config of the current site.
public static CreateConnection ( string connectionName ) : SqlConnection
connectionName string The name of the connection string.
return System.Data.SqlClient.SqlConnection

JsonReadOrDelete() public static method

Read from SQL objects and return as JSON. Uses the JsonReadOrDelete stored procedure to return limited record sets to the Sql client. Great for streaming pages of data to a stateless web client.
public static JsonReadOrDelete ( string objectName, int rowFrom, int rowTo ) : JsonResponse
objectName string Name of the table, view or object.
rowFrom int The row to fetch from.
rowTo int The row to fetch to.
return JsonResponse

JsonReadOrDelete() public static method

Read from SQL objects and return as JSON. Uses the JsonReadOrDelete stored procedure to return limited record sets to the Sql client. Great for streaming pages of data to a stateless web client.
public static JsonReadOrDelete ( string query, int rowFrom, int rowTo, System.Guid accountId, SqlParameter parameters, string orderBy, OrderDirection orderByDirection ) : JsonResponse
query string The query to execute. This will be turned into a vew that is removed when the HttpApplication is disposed.
rowFrom int The row to fetch from.
rowTo int The row to fetch to.
accountId System.Guid The account id.
parameters SqlParameter The parameters collection to use in the query.
orderBy string The column order by.
orderByDirection OrderDirection The order by direction.
return JsonResponse

JsonReadOrDelete() public static method

Read from SQL objects and return as JSON. Uses the JsonReadOrDelete stored procedure to return limited record sets to the Sql client. Great for streaming pages of data to a stateless web client.
public static JsonReadOrDelete ( string query, int rowFrom, int rowTo, SqlParameter parameters, string orderBy, OrderDirection orderByDirection ) : JsonResponse
query string The query to execute. This will be turned into a vew that is removed when the HttpApplication is disposed.
rowFrom int The row to fetch from.
rowTo int The row to fetch to.
parameters SqlParameter The parameters collection to use in the query.
orderBy string The column order by.
orderByDirection OrderDirection The order by direction.
return JsonResponse

JsonReadOrDelete() public static method

Read from SQL objects and return as JSON. Uses the JsonReadOrDelete stored procedure to return limited record sets to the Sql client. Great for streaming pages of data to a stateless web client.
public static JsonReadOrDelete ( string objectName, int rowFrom, int rowTo, SqlWhere where ) : JsonResponse
objectName string Name of the table, view or object.
rowFrom int The row to fetch from.
rowTo int The row to fetch to.
where SqlWhere The where clause object.
return JsonResponse

JsonReadOrDelete() public static method

Read from SQL objects and return as JSON. Uses the JsonReadOrDelete stored procedure to return limited record sets to the Sql client. Great for streaming pages of data to a stateless web client. Note: Delete requires a [RowVersion] rowversion column present in the table. State data is stored in the table UIColumns on a per user basis. Users are defined in Oda.Authentication class and in the table Accounts.
public static JsonReadOrDelete ( string objectName, int rowFrom, int rowTo, SqlWhere whereClause, System.Guid accountId, SqlWhere searchClause, string>.IDictionary aggregates, ICollection selectedRows, bool includeSchemaData, System.Int64 checksum, bool deleteSelection, string orderBy, OrderDirection orderByDirection ) : JsonResponse
objectName string Name of the table, view or object.
rowFrom int The row to fetch from.
rowTo int The row to fetch to.
whereClause SqlWhere The where clause object.
accountId System.Guid The account id.
searchClause SqlWhere The search clause object.
aggregates string>.IDictionary The aggregates to return if any.
selectedRows ICollection The selected rows. For use with the delete bit.
includeSchemaData bool If set to true then schema data will be included.
checksum System.Int64 The checksum of the table. This is the some of the rowversion column. For use with the delete bit.
deleteSelection bool if set to true then the rows defined in the selectedRows parameter will be deleted if the table checksome matches.
orderBy string The column order by.
orderByDirection OrderDirection The direction to order by.
return JsonResponse

JsonReadOrDelete() public static method

Read from SQL objects and return as JSON. Uses the JsonReadOrDelete stored procedure to return limited record sets to the Sql client. Great for streaming pages of data to a stateless web client.
public static JsonReadOrDelete ( string query, int rowFrom, int rowTo, string orderBy, OrderDirection orderByDirection ) : JsonResponse
query string The query to execute. This will be turned into a vew that is removed when the HttpApplication is disposed.
rowFrom int The row to fetch from.
rowTo int The row to fetch to.
orderBy string The column order by.
orderByDirection OrderDirection The order by direction.
return JsonResponse

Open() public static method

Opens the persistent connection.
public static Open ( ) : void
return void

Property Details

Connection public static property

The persistent Sql connection.
public static SqlConnection,System.Data.SqlClient Connection
return System.Data.SqlClient.SqlConnection