Skip to content
Adam edited this page Apr 23, 2015 · 6 revisions

#API Reference

SqlSharpener.Model.Column

Represents a column in a table.

Property Description
Name Gets the name.
DataTypes Gets the data types. R
IsIdentity Gets or sets a value indicating whether this instance is an identity column. Returns: true if this instance is an identity column; otherwise, false.
IsNullable Gets or sets a value indicating whether this instance is nullable. Returns: true if this instance is nullable; otherwise, false.
Precision Gets or sets the precision.
Scale Gets or sets the scale.
Length Gets or sets the length.

SqlSharpener.Model.Table

Represents a table in the model.

Property Description
Name Gets the name of the table.
Columns Gets the columns.

SqlSharpener.Model.SelectColumn

Represents a column in a SELECT statement in a stored procedure.

Property Description
Name Gets the name or alias.
DataTypes Gets the data types.

SqlSharpener.DataTypeHelper

Helps map a data type to similar datatypes in different environments.

ToDataType(System.String,SqlSharpener.TypeFormat,SqlSharpener.TypeFormat)

Converts the specified source data type into the specified destination data type.

Name Description
sourceDataType: The source data type. For example bigint.
sourceFormat: The format of the the sourceDataType parameter.
destinationFormat: The format to convert the sourceDataType parameter to.
Returns: The converted data type.

System.NotSupportedException:


GetMap(SqlSharpener.TypeFormat,System.String)

Gets a single data type dictionary with values for each TypeFormat by finding the specified entry in the list of data type dictionaries.

Name Description
lookupFormat: The TypeFormat of the lookupValue parameter.
lookupValue: The value to identify the dictionary to return.
Returns: The first data type dictionary that contains the specified TypeFormat and value.

SqlSharpener.TypeFormat

Enum of the different types of datatypes available.

Name Description
TypeFormat.SqlServerDbType The SQL server database type. Ex: "bigint"
TypeFormat.DotNetFrameworkType The dot net framework type. Ex: "Int64?"
TypeFormat.SqlDbTypeEnum The SqlDbTypeEnum type. Ex: "BigInt"
TypeFormat.SqlDataReaderSqlType The SQL data reader SQL type. Ex: "GetSqlInt64"
TypeFormat.DbTypeEnum The database type enum. Ex: "Int64"
TypeFormat.SqlDataReaderDbType The SQL data reader database type. Ex: "GetInt64"

SqlSharpener.Model.Parameter

Represents a parameter of a stored procedure.

Property Description
Name Gets the name. Returns: The name.
DataTypes Gets the data types for this parameter. Returns: The data types.
IsOutput Gets a value indicating whether this instance is an output parameter. Returns: true if this instance is an output parameter; otherwise, false.

SqlSharpener.Model.Procedure

Represents a stored procedures

Property Description
Name Gets the name used for methods. Returns: The name.
RawName Gets the raw name of the stored procedure. Returns: The stored procedure name verbatim.
Prefix Gets the prefix. Returns: The prefix.
Parameters Gets the parameters. Returns: The parameters.
Selects Gets the selects. Returns: The selects.

SqlSharpener.MetaBuilder

Creates a model from the specified sql files.


MetaBuilder.#ctor(System.String[])

Initializes a new instance of the class.

Name Description
sqlPaths: The paths to the *.sql files.

LoadModel()

Creates a new TSqlModel, loads all *.sql files specified in the SqlPaths property into the new model, and then parses the model.

System.InvalidOperationException: No path to *.sql files exists in SqlPaths properties.


LoadModel(System.String[])

Creates a new TSqlModel, loads each specified sql statement into the new model, and then parses the model

Name Description
sqlStatements: One or more sql statements to load, such as CREATE TABLE or CREATE PROCEDURE statements.
Property Description
ProcedurePrefix Gets or sets the prefix to strip off the procedure name when generating the method name. Returns: The procedure prefix.
SqlPaths List of directories where *.sql exist that should be added to the model. Returns: The SQL paths.
Procedures Objects representing the meta data parsed from stored procedures in the model. Returns: The procedures.
Tables Objects representing the meta data parsed from the tables in the model. Returns: The tables.

SqlSharpener.Model.Select

Represents a SELECT statement in a stored procedure.

Property Description
Columns Gets the columns. Returns: The columns.
IsTopOne Gets a value indicating whether this instance uses a TOP 1 clause. Returns: true if this instance uses a TOP 1 clause; otherwise, false.
TableAliases Gets the table aliases.

SqlSharpener.ProcedureHelper

Helper class to handle some of the more complex code generation.

GetNamespace(System.String)

Scrubs the outputNamespace parameter to ensure it is not null.

Name Description
outputNameSpace: The outputNameSpace T4 parameter.
Returns: The value of outputNameSpace if not null.

System.ArgumentNullException: outputNamespace cannot be null.


GetConnStrVar(System.String)

Scrubs the connectionStringVariableName parameter to ensure it is not null.

Name Description
connectionStringVariableName: The connectionStringVariableName T4 parameter.
Returns: The value of connectionStringVariableName if not null.

System.ArgumentNullException: connectionStringVariableName cannot be null.


GetDtoObject(SqlSharpener.Model.Procedure,System.Int32)

Gets the DTO return objects that represent a row of each result set of each procedure.

Name Description
proc: The procedure to generate the DTO from.
indent: The number of tabs to indent the generated code.
Returns: The generated DTO objects.

GetReturnType(SqlSharpener.Model.Procedure)

Gets the type of object the procedure's function will return.

Name Description
proc: The procedure to get the return type for.
Returns: The generated return type.

GetReturnVariable(SqlSharpener.Model.Procedure)

Gets the variable declaration statement for the return value.

Name Description
proc: The procedure to get the return variable declaration statement.
Returns: The generated declaration statement.

GetReturnXmlComment(SqlSharpener.Model.Procedure)

Gets the Xml comment to place in the <returns> element.

Name Description
proc: The procedure to get the return variable declaration statement.
Returns: The Xml comment

GetMethodParamList(SqlSharpener.Model.Procedure)

Gets the parameter list for the method.

Name Description
proc: The procedure to get the parameter list for.
Returns: The generated parameter list.

GetSqlParamList(SqlSharpener.Model.Procedure,System.Int32)

Gets the generated SqlParameter objects with assigned values.

Name Description
proc: The procedure to get the generated SqlParameters for.
indent: The number of tabs to indent the generated code.
Returns: The generated SqlParameters

GetExecuteStatement(SqlSharpener.Model.Procedure,System.Int32)

Gets the generated statement that executes the stored procedure and loads the results into the return variable.

Name Description
proc: The procedure to get the generated execute statement for.
indent: The number of tabs to indent the generated code.
Returns: The generated code.
Clone this wiki locally