C# Класс SqlAzureWriterStormApplication.SqlAzureBolt

OVERVIEW: SqlAzureWriterBolt - A bolt that can insert, upsert or delete from Sql Azure. Change or override the execute method to as per your requirements. The bolt uses parameterized T-SQL statements based on specified table schema PRE-REQUISITES: 1. Sql Azure Server, Database and Table - All values need to be specifed in AppSettings a. SqlAzureConnectionString - your Sql Azure server connection string b. SqlAzureTableName - your Sql Azure table name c. SqlAzureTableColumns - comma separated column names, required for query building 2. Sql Table Schema a. Note that Sql Azure requires your table schema to have a clustered index b. This can be easily acheived by including an identity column as the primary key which gets automatically generated on each insert c. For e.g.: Create Table #your_table# ([ID] INT IDENTITY PRIMARY KEY, ... ASSUMPTIONS: 1. The type infering of tuple field (SqlParameter) is left to the provider as we use AddWithValue. To avoid surprises you can specify SqlDbType directly. NUGET: 1. SCP.Net - http://www.nuget.org/packages/Microsoft.SCP.Net.SDK/ 2. Sql Transient Fault handling - http://www.nuget.org/packages/EnterpriseLibrary.TransientFaultHandling.Data REFERENCES: 1. Reliably connect to Azure SQL Database - https://msdn.microsoft.com/en-us/library/azure/dn864744.aspx
Наследование: ISCPBolt
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
context Context
enableAck bool

Private Properties

Свойство Тип Описание

Открытые методы

Метод Описание
Delete ( List keys, List row ) : void
Execute ( SCPTuple tuple ) : void
ExecuteCommand ( SqlCommand sqlCommand ) : void
GenerateInsertTSql ( ) : string

Generates T-SQL Insert statement

GenerateUpdateTSql ( List keys ) : string
GenerateUpsertTSql ( List keys ) : string
GenerateWhereTSql ( List keys ) : string

Instead of using TableColumns we will use the keys list

Get ( Context context, Object>.Dictionary parms ) : SqlAzureBolt

A delegate method to return the instance of this class

HandleException ( Exception ex ) : void

Log the exception and reset any prepared commands and connections

InitializeSqlAzure ( ) : void

Initialize the Sql Azure settings and connections

InitializeSqlAzureConnection ( ) : void

Initialize Sql Azure Connection if not open

Insert ( List row ) : void
PrepareSqlDeleteCommand ( List keys, List row ) : void

Prepares SQL Delete command

PrepareSqlInsertCommand ( List row ) : void

Prepares Sql Insert Command

PrepareSqlUpsertCommand ( List keys, List row ) : void
SqlAzureBolt ( Context context, Object>.Dictionary parms ) : Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling
Upsert ( List keys, List row ) : void

Описание методов

Delete() публичный Метод

public Delete ( List keys, List row ) : void
keys List
row List
Результат void

Execute() публичный Метод

public Execute ( SCPTuple tuple ) : void
tuple SCPTuple
Результат void

ExecuteCommand() публичный Метод

public ExecuteCommand ( SqlCommand sqlCommand ) : void
sqlCommand System.Data.SqlClient.SqlCommand
Результат void

GenerateInsertTSql() публичный Метод

Generates T-SQL Insert statement
public GenerateInsertTSql ( ) : string
Результат string

GenerateUpdateTSql() публичный Метод

public GenerateUpdateTSql ( List keys ) : string
keys List
Результат string

GenerateUpsertTSql() публичный Метод

public GenerateUpsertTSql ( List keys ) : string
keys List
Результат string

GenerateWhereTSql() публичный Метод

Instead of using TableColumns we will use the keys list
public GenerateWhereTSql ( List keys ) : string
keys List
Результат string

Get() публичный статический Метод

A delegate method to return the instance of this class
public static Get ( Context context, Object>.Dictionary parms ) : SqlAzureBolt
context Context SCP Context, automatically passed by SCP.Net
parms Object>.Dictionary
Результат SqlAzureBolt

HandleException() публичный Метод

Log the exception and reset any prepared commands and connections
public HandleException ( Exception ex ) : void
ex System.Exception The exception thrown
Результат void

InitializeSqlAzure() публичный Метод

Initialize the Sql Azure settings and connections
public InitializeSqlAzure ( ) : void
Результат void

InitializeSqlAzureConnection() публичный Метод

Initialize Sql Azure Connection if not open
public InitializeSqlAzureConnection ( ) : void
Результат void

Insert() публичный Метод

public Insert ( List row ) : void
row List
Результат void

PrepareSqlDeleteCommand() публичный Метод

Prepares SQL Delete command
public PrepareSqlDeleteCommand ( List keys, List row ) : void
keys List Index of keys within the tuple fields which need to be deleted
row List
Результат void

PrepareSqlInsertCommand() публичный Метод

Prepares Sql Insert Command
public PrepareSqlInsertCommand ( List row ) : void
row List
Результат void

PrepareSqlUpsertCommand() публичный Метод

public PrepareSqlUpsertCommand ( List keys, List row ) : void
keys List
row List
Результат void

SqlAzureBolt() публичный Метод

public SqlAzureBolt ( Context context, Object>.Dictionary parms ) : Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling
context Context
parms Object>.Dictionary
Результат Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling

Upsert() публичный Метод

public Upsert ( List keys, List row ) : void
keys List
row List
Результат void

Описание свойств

context публичное свойство

public Context context
Результат Context

enableAck публичное свойство

public bool enableAck
Результат bool