C# Class 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
Inheritance: ISCPBolt
Mostra file Open project: Azure-Samples/hdinsight-dotnet-storm-powerbi

Public Properties

Property Type Description
context Context
enableAck bool

Private Properties

Property Type Description

Public Methods

Method Description
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

Method Details

Delete() public method

public Delete ( List keys, List row ) : void
keys List
row List
return void

Execute() public method

public Execute ( SCPTuple tuple ) : void
tuple SCPTuple
return void

ExecuteCommand() public method

public ExecuteCommand ( SqlCommand sqlCommand ) : void
sqlCommand System.Data.SqlClient.SqlCommand
return void

GenerateInsertTSql() public method

Generates T-SQL Insert statement
public GenerateInsertTSql ( ) : string
return string

GenerateUpdateTSql() public method

public GenerateUpdateTSql ( List keys ) : string
keys List
return string

GenerateUpsertTSql() public method

public GenerateUpsertTSql ( List keys ) : string
keys List
return string

GenerateWhereTSql() public method

Instead of using TableColumns we will use the keys list
public GenerateWhereTSql ( List keys ) : string
keys List
return string

Get() public static method

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
return SqlAzureBolt

HandleException() public method

Log the exception and reset any prepared commands and connections
public HandleException ( Exception ex ) : void
ex System.Exception The exception thrown
return void

InitializeSqlAzure() public method

Initialize the Sql Azure settings and connections
public InitializeSqlAzure ( ) : void
return void

InitializeSqlAzureConnection() public method

Initialize Sql Azure Connection if not open
public InitializeSqlAzureConnection ( ) : void
return void

Insert() public method

public Insert ( List row ) : void
row List
return void

PrepareSqlDeleteCommand() public method

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
return void

PrepareSqlInsertCommand() public method

Prepares Sql Insert Command
public PrepareSqlInsertCommand ( List row ) : void
row List
return void

PrepareSqlUpsertCommand() public method

public PrepareSqlUpsertCommand ( List keys, List row ) : void
keys List
row List
return void

SqlAzureBolt() public method

public SqlAzureBolt ( Context context, Object>.Dictionary parms ) : Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling
context Context
parms Object>.Dictionary
return Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling

Upsert() public method

public Upsert ( List keys, List row ) : void
keys List
row List
return void

Property Details

context public_oe property

public Context context
return Context

enableAck public_oe property

public bool enableAck
return bool