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
Afficher le fichier Open project: Azure-Samples/hdinsight-dotnet-storm-powerbi

Méthodes publiques

Свойство Type Description
context Context
enableAck bool

Private Properties

Свойство Type Description

Méthodes publiques

Méthode 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 méthode

public Delete ( List keys, List row ) : void
keys List
row List
Résultat void

Execute() public méthode

public Execute ( SCPTuple tuple ) : void
tuple SCPTuple
Résultat void

ExecuteCommand() public méthode

public ExecuteCommand ( SqlCommand sqlCommand ) : void
sqlCommand System.Data.SqlClient.SqlCommand
Résultat void

GenerateInsertTSql() public méthode

Generates T-SQL Insert statement
public GenerateInsertTSql ( ) : string
Résultat string

GenerateUpdateTSql() public méthode

public GenerateUpdateTSql ( List keys ) : string
keys List
Résultat string

GenerateUpsertTSql() public méthode

public GenerateUpsertTSql ( List keys ) : string
keys List
Résultat string

GenerateWhereTSql() public méthode

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

Get() public static méthode

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
Résultat SqlAzureBolt

HandleException() public méthode

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

InitializeSqlAzure() public méthode

Initialize the Sql Azure settings and connections
public InitializeSqlAzure ( ) : void
Résultat void

InitializeSqlAzureConnection() public méthode

Initialize Sql Azure Connection if not open
public InitializeSqlAzureConnection ( ) : void
Résultat void

Insert() public méthode

public Insert ( List row ) : void
row List
Résultat void

PrepareSqlDeleteCommand() public méthode

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
Résultat void

PrepareSqlInsertCommand() public méthode

Prepares Sql Insert Command
public PrepareSqlInsertCommand ( List row ) : void
row List
Résultat void

PrepareSqlUpsertCommand() public méthode

public PrepareSqlUpsertCommand ( List keys, List row ) : void
keys List
row List
Résultat void

SqlAzureBolt() public méthode

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

Upsert() public méthode

public Upsert ( List keys, List row ) : void
keys List
row List
Résultat void

Property Details

context public_oe property

public Context context
Résultat Context

enableAck public_oe property

public bool enableAck
Résultat bool