コード例 #1
0
        private string GetLookupDataAndWriteToDropdown(SQLTableColumn column)
        {
            StringBuilder lookupDataAndDropDown = new StringBuilder();

            string tableName        = column.TableName;
            string loweredTableName = Library.LowerFirstCharacter(tableName);
            string primaryKey       = Library.LowerFirstCharacter(column.ParentTable.PrimaryKey.Name);
            string firstColumn      = Library.LowerFirstCharacter(column.ParentTable.Columns[1].Name);

            lookupDataAndDropDown.AppendLine($"\tasync get{tableName}Data() {{");
            lookupDataAndDropDown.AppendLine($"\t\tconst response = await fetch(process.env.REACT_APP_API_ENDPOINT + '{loweredTableName}');");
            lookupDataAndDropDown.AppendLine("\t\tconst data = await response.json();");
            lookupDataAndDropDown.AppendLine($"\t\tthis.setState({{ {loweredTableName}s: data.map(({loweredTableName}) => new {tableName}Option({loweredTableName}.{primaryKey}, {loweredTableName}.{primaryKey}, {loweredTableName}.{firstColumn})), loading: false }});");
            lookupDataAndDropDown.AppendLine("}");
            lookupDataAndDropDown.AppendLine("");
            lookupDataAndDropDown.AppendLine($"\tDisplay{tableName}Dropdown() {{");
            lookupDataAndDropDown.AppendLine("\t\tconst { value } = this.state;");
            lookupDataAndDropDown.AppendLine("\t\treturn (<Dropdown");
            lookupDataAndDropDown.AppendLine($"\t\t\tplaceholder='Select {tableName}'");
            lookupDataAndDropDown.AppendLine("\t\t\tfluid");
            lookupDataAndDropDown.AppendLine("\t\t\tselection");
            lookupDataAndDropDown.AppendLine("\t\t\tsearch");
            lookupDataAndDropDown.AppendLine($"\t\t\toptions={{this.state.{loweredTableName}s}}");
            lookupDataAndDropDown.AppendLine($"\t\t\tname=\"{primaryKey}\"");
            lookupDataAndDropDown.AppendLine("\t\t\tonChange={this.handleDropDownChange}");
            lookupDataAndDropDown.AppendLine("\t\t\tvalue={value}");
            lookupDataAndDropDown.AppendLine("\t\t/>");
            lookupDataAndDropDown.AppendLine("\t\t);");
            lookupDataAndDropDown.AppendLine("\t}");

            return(lookupDataAndDropDown.ToString());
        }
コード例 #2
0
        private string ForeignKeyCode(SQLTable table, CodeFunction codeFunction, bool prepend)
        {
            StringBuilder foreignKeyCode = new StringBuilder();

            foreach (SQLForeignKeyRelation foreignKey in sQLForeignKeyRelationsForTable(table))
            {
                SQLTableColumn column = foreignKey.ReferencedTableColumn;
                if (prepend)
                {
                    foreignKeyCode.Insert(0, codeFunction(column.ParentTable) + Environment.NewLine);
                }
                else
                {
                    foreignKeyCode.Append(codeFunction(column.ParentTable) + Environment.NewLine);
                }

                string childForeignKeyCreateFunctions = ForeignKeyCode(column.ParentTable, codeFunction, prepend);
                if (childForeignKeyCreateFunctions != "")
                {
                    if (prepend)
                    {
                        foreignKeyCode.Insert(0, childForeignKeyCreateFunctions);
                    }
                    else
                    {
                        foreignKeyCode.Append(childForeignKeyCreateFunctions);
                    }
                }
            }

            return(foreignKeyCode.ToString());
        }
コード例 #3
0
        private string GenerateBindText(string statementParameter, SQLTableColumn column, int columnCounter, bool includeClassNameInParameter)
        {
            string parameterToBind = $"{(includeClassNameInParameter ? Library.LowerFirstCharacter(column.TableName) + "." : "")}{Library.LowerFirstCharacter(column.Name)}";

            return(column.sqlLiteDataType switch
            {
                sqlLiteStorageDataTypes.intStore => $"sqlite3_bind_int({statementParameter}, {columnCounter}, {parameterToBind}) == SQLITE_OK",
                sqlLiteStorageDataTypes.floatStore => (column.DataType == SQLDataTypes.dateTime ? $"sqlite3_bind_double({statementParameter}, {columnCounter}, {parameterToBind}.timeIntervalSince1970) == SQLITE_OK": $"sqlite3_bind_double({statementParameter}, {columnCounter}, {parameterToBind}) == SQLITE_OK"),
                sqlLiteStorageDataTypes.textStore => $"sqlite3_bind_{column.sqlLiteBindType}({statementParameter}, {columnCounter}, NSString(string: {parameterToBind}).utf8String, -1, nil) == SQLITE_OK",
                sqlLiteStorageDataTypes.blobStore => throw new NotImplementedException("Blob storage bind not implemented"),
                _ => throw new SQLDataTypeNotHandledInSwiftDatabaseBindText(column.DataType)
            });
コード例 #4
0
        private string CreateLookupClass(SQLTableColumn column)
        {
            StringBuilder lookupClass = new StringBuilder();

            lookupClass.AppendLine($"export class {column.TableName}Option {{");

            lookupClass.AppendLine("\tconstructor(key, value, text) {");

            lookupClass.AppendLine("\t\tthis.text = text;");
            lookupClass.AppendLine("\t\tthis.key = key;");
            lookupClass.AppendLine("\t\tthis.value = value;");
            lookupClass.AppendLine("\t}");
            lookupClass.AppendLine("}");

            return(lookupClass.ToString());
        }
コード例 #5
0
        void GenerateForeignKeyStatements(SQLTable table, StringBuilder sqlStatement)
        {
            List <SQLForeignKeyRelation> foreignKeys = sQLForeignKeyRelationsForTable(table);

            foreach (SQLForeignKeyRelation foreignKey in foreignKeys)
            {
                SQLTableColumn column = foreignKey.ReferencedTableColumn;

                sqlStatement.AppendLine(go);
                sqlStatement.Append("CREATE PROCEDURE [dbo].[" + table.Name + "GetBy" + column.Name + "]" + Environment.NewLine);
                sqlStatement.Append("@" + column.Name + " " + column.DataType.ToString() + Environment.NewLine);
                GenerateSelectStatement(table, sqlStatement);

                sqlStatement.AppendLine(sqlRowIdentifier(column.Name));

                sqlStatement.AppendLine(end);
                sqlStatement.AppendLine(procedureDivider);
            }
        }
コード例 #6
0
        public static List <SQLTableColumn> LoadColumnsForTable(string tableName, string connectionString, SQLTable parentTable, ref List <SQLTable> databaseTables)
        {
            List <SQLTableColumn> columns = new List <SQLTableColumn>();

            string selectStatement;

            selectStatement = "select COLUMN_NAME, TABLE_NAME, ORDINAL_POSITION, IS_NULLABLE, CHARACTER_MAXIMUM_LENGTH, DATA_TYPE, NUMERIC_PRECISION, NUMERIC_SCALE, DATETIME_PRECISION from INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" + tableName + "'";

            SqlDataReader dataReader = SQLDataServer.ExecuteSQLStringReturnDataReader(selectStatement, connectionString);

            while (dataReader.Read())
            {
                SQLTableColumn column = new SQLTableColumn();

                column.Name              = Convert.ToString(dataReader["COLUMN_NAME"]);
                column.TableName         = Convert.ToString(dataReader["TABLE_NAME"]);
                column.OrdinalPosition   = Convert.ToInt32(dataReader["ORDINAL_POSITION"]);
                column.Nullable          = DBBooleanValues.ReturnBooleanFromYesOrNo(dataReader["IS_NULLABLE"]);
                column.DataType          = Convert.ToString(dataReader["DATA_TYPE"]);
                column.MaximumLength     = DBNullReturnValues.Return0(dataReader["CHARACTER_MAXIMUM_LENGTH"]);
                column.NumericPrecision  = DBNullReturnValues.Return0(dataReader["NUMERIC_PRECISION"]);
                column.NumericScale      = DBNullReturnValues.Return0(dataReader["NUMERIC_SCALE"]);
                column.DateTimePrecision = DBNullReturnValues.Return0(dataReader["DATETIME_PRECISION"]);

                column.ParentTable = parentTable;

                if (column.OrdinalPosition == 1)
                {
                    column.PrimaryKey = true;
                }

                column.ForeignKeys = SQLForeignKeyRelation.LoadForeignKeysForColumn(column.ParentTable.id, column.OrdinalPosition, connectionString, ref databaseTables);

                columns.Add(column);
            }

            dataReader.Close();

            return(columns);
        }
コード例 #7
0
        void GenerateForeignKeyDeleteStatements(SQLTable table, StringBuilder sqlStatement)
        {
            List <SQLForeignKeyRelation> foreignKeys = sQLForeignKeyRelationsForTable(table);

            foreach (SQLForeignKeyRelation foreignKey in foreignKeys)
            {
                SQLTableColumn column = foreignKey.ReferencedTableColumn;

                sqlStatement.AppendLine(go);
                sqlStatement.AppendLine("CREATE PROCEDURE [dbo].[" + table.Name + "DeleteFor" + column.TableName + "]" + Environment.NewLine);

                sqlStatement.AppendLine($"@{column.Name} {column.DataType}");
                sqlStatement.AppendLine(sqlAs);
                sqlStatement.AppendLine(begin);
                sqlStatement.AppendLine(setNoCount);

                sqlStatement.AppendLine($"DELETE FROM [{table.Name}]");
                sqlStatement.AppendLine(sqlRowIdentifier(column.Name));

                sqlStatement.AppendLine(end);
            }
        }
コード例 #8
0
        public static List <SQLTable> LoadTables(string connectionString)
        {
            List <SQLTable> tables = new List <SQLTable>();
            SqlDataReader   dataReader;

            dataReader = SQLDataServer.ExecuteSQLStringReturnDataReader("select name, object_id from sys.tables where name <> 'sysdiagrams' and name not like 'aspnet_%'", connectionString);

            while (dataReader.Read())
            {
                SQLTable table = new SQLTable();

                table.Name = Convert.ToString(dataReader["name"]);
                table.id   = Convert.ToInt32(dataReader["object_id"]);

                table.Columns = SQLTableColumn.LoadColumnsForTable(table.Name, connectionString, table, ref tables);

                tables.Add(table);
            }

            dataReader.Close();

            return(tables);
        }
コード例 #9
0
        private string CreateInputsCode(SQLTableColumn column)
        {
            StringBuilder inputsCode = new StringBuilder();

            string loweredName = Library.LowerFirstCharacter(column.Name);

            inputsCode.AppendLine("\t\t\t\t<label>");

            bool   usedropdown = false;
            string tableName   = "";

            foreach (SQLForeignKeyRelation foreignKeyRelation in foreignKeys)
            {
                if (foreignKeyRelation.ParentTableColum == column)
                {
                    usedropdown = true;
                    tableName   = foreignKeyRelation.ReferencedTableColumn.TableName;
                }
            }

            if (!usedropdown)
            {
                inputsCode.AppendLine("\t\t\t\t\t" + column.Name + ":");
                inputsCode.AppendLine($"\t\t\t\t\t<input type=\"{column.htmlInputFormType}\" name=\"{loweredName}\" value={{this.state.{loweredName}}} onChange={{this.handleInputChange}} />");
            }
            else
            {
                loweredName = Library.LowerFirstCharacter(tableName);
                inputsCode.AppendLine($"\t\t\t\t\t{tableName}");
                inputsCode.AppendLine($"\t\t\t\t\t{{{loweredName}Dropdown}}");
            }

            inputsCode.AppendLine("\t\t\t\t</label>");

            return(inputsCode.ToString());
        }
コード例 #10
0
 string AddParameter(string parameterValue, SQLTableColumn column)
 {
     return($"SQLDataServer.AddParameter(ref parameters, \"@{column.Name}\", {parameterValue}, SqlDbType.{column.dotNetSqlDataTypes}, {column.MaximumLength});");
 }
コード例 #11
0
 string AddParameter(SQLTableColumn column)
 {
     return($"SQLDataServer.AddParameter(ref parameters, \"@{column.Name}\", {Library.LowerFirstCharacter(column.TableName)}.{column.Name}, SqlDbType.{column.dotNetSqlDataTypes}, {column.MaximumLength});");
 }
コード例 #12
0
        internal override void GenerateFilePerTable(SQLTable table)
        {
            List <SQLForeignKeyRelation> foreignKeys = sQLForeignKeyRelationsForTable(table);

            classText.AppendLine("using DataServer;");
            classText.AppendLine("using System;");
            classText.AppendLine("using System.Collections.Generic;");
            classText.AppendLine("using System.Data;");
            classText.AppendLine("using System.Data.SqlClient;");
            classText.AppendLine($"using {_nameSpace}.Repository;");
            classText.AppendLine("");

            classText.AppendLine($"namespace {_nameSpace}.SqlRepository");
            classText.AppendLine("{");
            classText.AppendLine($"\tpublic class {table.Name}RepositorySql : IRepository<{dataObjectClassIdentifier}, {table.PrimaryKey.cSharpDataType}>");
            classText.AppendLine("\t{");
            classText.AppendLine("\t\t#region Loading Methods");
            classText.AppendLine($"\t\tpublic List<{dataObjectClassIdentifier}> GetAll()");
            classText.AppendLine("\t\t{");
            classText.AppendLine($"\t\t\treturn Populate{table.Name}List(\"{table.Name}GetAll\", new List<SqlParameter>());");
            classText.AppendLine("\t\t}");
            classText.AppendLine("");

            classText.AppendLine($"\t\tpublic {dataObjectClassIdentifier} GetByID({table.PrimaryKey.cSharpDataType} {Library.LowerFirstCharacter(table.PrimaryKey.Name)})");
            classText.AppendLine("\t\t{");
            classText.AppendLine("\t\t\tList<SqlParameter> parameters = new List<SqlParameter>();");
            classText.AppendLine($"\t\t\tSQLDataServer.AddParameter(ref parameters, \"@{table.PrimaryKey.Name}\", {Library.LowerFirstCharacter(table.PrimaryKey.Name)}, SqlDbType.{table.PrimaryKey.dotNetSqlDataTypes}, {table.PrimaryKey.MaximumLength});");
            classText.AppendLine($"\t\t\tList<{dataObjectClassIdentifier}> {table.Name}Bases = Populate{table.Name}List(\"{table.Name}GetByID\", parameters);");
            classText.AppendLine("");
            classText.AppendLine($"\t\t\t\tswitch ({table.Name}Bases.Count)");
            classText.AppendLine("\t\t\t\t{");
            classText.AppendLine("\t\t\t\t\tcase 1:");
            classText.AppendLine($"\t\t\t\t\t\treturn {table.Name}Bases[0];");
            classText.AppendLine("\t\t\t\t\tcase 0:");
            classText.AppendLine("\t\t\t\t\t\treturn null;");
            classText.AppendLine("\t\t\t\t\tdefault:");
            classText.AppendLine("\t\t\t\t\t\tthrow new Exception(\"Get by ID returning more than one record\");");
            classText.AppendLine("\t\t\t\t}");
            classText.AppendLine("\t\t}");
            classText.AppendLine("");


            foreach (SQLForeignKeyRelation foreignKeyRelation in foreignKeys)
            {
                SQLTableColumn column = foreignKeyRelation.ReferencedTableColumn;

                classText.AppendLine($"\t\tpublic List<{dataObjectClassIdentifier}> GetBy{column.Name}({column.cSharpDataType} {Library.LowerFirstCharacter(column.Name)})");
                classText.AppendLine("\t\t{");
                classText.AppendLine("\t\t\tList<SqlParameter> parameters = new List<SqlParameter>();");
                classText.AppendLine($"\t\t\tSQLDataServer.AddParameter(ref parameters, \"@{column.Name}\", {Library.LowerFirstCharacter(column.Name)}, SqlDbType.{column.dotNetSqlDataTypes}, {column.MaximumLength});");
                classText.AppendLine($"\t\t\treturn Populate{table.Name}List(\"{table.Name}GetBy{column.Name}\", parameters);");
                classText.AppendLine("\t\t}");
                classText.AppendLine("");
            }


            classText.AppendLine("");
            classText.AppendLine($"\t\tprivate List<{dataObjectClassIdentifier}> Populate{table.Name}List(string storedProcedure, List<SqlParameter> parameters)");
            classText.AppendLine("\t\t{");

            //Check for guid columns as they need to use their ordinal to be identified
            foreach (SQLTableColumn column in table.Columns)
            {
                if (column.DataType == SQLDataTypes.uniqueIdentifier || column.DataType == SQLDataTypes.timeType)
                {
                    classText.AppendLine($"\t\t\tint {Library.LowerFirstCharacter(column.Name)}Column = {(column.OrdinalPosition - 1)};");
                }
            }
            classText.AppendLine("");

            classText.AppendLine($"\t\t\tList<{dataObjectClassIdentifier}> {Library.LowerFirstCharacter(table.Name)}s = new List<{dataObjectClassIdentifier}>();");
            classText.AppendLine("");
            classText.AppendLine($"\t\t\tSqlDataReader {Library.LowerFirstCharacter(table.Name)}sData = SQLDataServer.ExecuteSPReturnDataReader(storedProcedure, parameters);");
            classText.AppendLine($"\t\t\twhile ({Library.LowerFirstCharacter(table.Name)}sData.Read())");
            classText.AppendLine("\t\t\t{");

            if (table.PrimaryKey.DataType == SQLDataTypes.uniqueIdentifier)
            {
                classText.AppendLine($"\t\t\t\t{dataObjectClassIdentifier} {Library.LowerFirstCharacter(table.Name)} = new {dataObjectClassIdentifier}({Library.LowerFirstCharacter(table.Name)}sData.GetGuid({Library.LowerFirstCharacter(table.PrimaryKey.Name)}Column));");
            }
            else
            {
                classText.AppendLine($"\t\t\t\t{dataObjectClassIdentifier} {Library.LowerFirstCharacter(table.Name)} = new {dataObjectClassIdentifier}(Convert.ToInt32({Library.LowerFirstCharacter(table.Name)}sData[\"{table.PrimaryKey.Name}\"]));");
            }
            foreach (SQLTableColumn column in table.Columns)
            {
                if (!column.PrimaryKey)
                {
                    if (column.Nullable)
                    {
                        classText.AppendLine("");
                        classText.AppendLine($"\t\t\t\tif ({Library.LowerFirstCharacter(table.Name)}sData[\"{column.Name}\"] != DBNull.Value)");
                        classText.Append("\t");
                    }

                    classText.Append($"\t\t\t\t{Library.LowerFirstCharacter(table.Name)}.{column.Name} = ");

                    string dataReaderReadStatement;

                    switch (column.DataType)
                    {
                    case SQLDataTypes.uniqueIdentifier:
                        dataReaderReadStatement = $"{Library.LowerFirstCharacter(table.Name)}sData.GetGuid({Library.LowerFirstCharacter(column.Name)}Column);";
                        break;

                    case SQLDataTypes.intData:
                        dataReaderReadStatement = $"Convert.ToInt32({Library.LowerFirstCharacter(table.Name)}sData[\"{column.Name}\"]);";
                        break;

                    case SQLDataTypes.varChar:
                        dataReaderReadStatement = $"Convert.ToString({Library.LowerFirstCharacter(table.Name)}sData[\"{column.Name}\"]);";
                        break;

                    case SQLDataTypes.bit:
                        dataReaderReadStatement = $"Convert.ToBoolean({Library.LowerFirstCharacter(table.Name)}sData[\"{column.Name}\"]);";
                        break;

                    case SQLDataTypes.dateTime:
                        dataReaderReadStatement = $"Convert.ToDateTime({Library.LowerFirstCharacter(table.Name)}sData[\"{column.Name}\"]);";
                        break;

                    case SQLDataTypes.varBinary:
                        dataReaderReadStatement = "0; //to be honest, I'm a little surpised";
                        break;

                    case SQLDataTypes.decimalData:
                        dataReaderReadStatement = $"Convert.ToDecimal({Library.LowerFirstCharacter(table.Name)}sData[\"{column.Name}\"]);";
                        break;

                    case SQLDataTypes.floatData:
                        dataReaderReadStatement = $"(float){Library.LowerFirstCharacter(table.Name)}sData[\"{column.Name}\"];";
                        break;

                    case SQLDataTypes.binary:
                        dataReaderReadStatement = "Need another look at this";
                        break;

                    case SQLDataTypes.ncharData:
                        dataReaderReadStatement = $"Convert.ToString({Library.LowerFirstCharacter(table.Name)}sData[\"{column.Name}\"]);";
                        break;

                    case SQLDataTypes.charType:
                        dataReaderReadStatement = $"Convert.ToString({Library.LowerFirstCharacter(table.Name)}sData[\"{column.Name}\"]);";
                        break;

                    case SQLDataTypes.timeType:
                        dataReaderReadStatement = $"{Library.LowerFirstCharacter(table.Name)}sData.GetTimeSpan({Library.LowerFirstCharacter(column.Name)}Column);";
                        break;

                    case SQLDataTypes.moneyType:
                        dataReaderReadStatement = $"Convert.ToDecimal({Library.LowerFirstCharacter(table.Name)}sData[\"{column.Name}\"]);";
                        break;

                    default:
                        throw new SQLDBTypeNotSupported(column.DataType);
                    }

                    classText.AppendLine(dataReaderReadStatement);

                    if (column.Nullable)
                    {
                        classText.AppendLine("");
                    }
                }
            }
            classText.AppendLine("");
            classText.AppendLine($"\t\t\t\t{Library.LowerFirstCharacter(table.Name)}s.Add({Library.LowerFirstCharacter(table.Name)});");
            classText.AppendLine("\t\t\t}");
            classText.AppendLine($"\t\t\t{Library.LowerFirstCharacter(table.Name)}sData.Close();");
            classText.AppendLine("");
            classText.AppendLine($"\t\t\treturn {Library.LowerFirstCharacter(table.Name)}s;");
            classText.AppendLine("\t\t}");
            classText.AppendLine("");
            classText.AppendLine("\t\t#endregion");


            classText.AppendLine("");
            classText.AppendLine("\t\t#region Updating the database");

            classText.AppendLine($"\t\tpublic void Save({dataObjectClassIdentifier} {Library.LowerFirstCharacter(table.Name)})");
            classText.AppendLine("\t\t{");

            classText.AppendLine("\t\t\tList<SqlParameter> parameters = new List<SqlParameter>();");
            classText.AppendLine("");

            foreach (SQLTableColumn column in table.Columns)
            {
                if (!column.PrimaryKey)
                {
                    classText.AppendLine($"\t\t\t{AddParameter(column)}");
                }
            }

            foreach (SQLTableColumn column in table.Columns)
            {
                if (column.PrimaryKey)
                {
                    if (column.DataType == SQLDataTypes.uniqueIdentifier)
                    {
                        classText.AppendLine($"\t\t\tif ({Library.LowerFirstCharacter(table.Name)}.{column.Name} == Guid.Empty)");
                        classText.AppendLine("\t\t\t{");
                        classText.AppendLine($"\t\t\t\t{Library.LowerFirstCharacter(table.Name)}.{column.Name} = SQLDataServer.ExecuteSPReturnGuid(\"{table.Name}Insert\", parameters);");
                        classText.AppendLine("\t\t\t}");
                        classText.AppendLine("\t\t\telse");
                        classText.AppendLine("\t\t\t{");
                        classText.AppendLine($"\t\t\t\t{AddParameter(column)}");
                        classText.AppendLine($"\t\t\t\t{ExecuteSP(table.Name, "Update")}");
                        classText.AppendLine("\t\t\t}");
                    }
                    else
                    {
                        classText.AppendLine($"\t\t\tif ({Library.LowerFirstCharacter(table.Name)}.{column.Name} == 0)");
                        classText.AppendLine("\t\t\t{");
                        classText.AppendLine($"\t\t\t\t{Library.LowerFirstCharacter(table.Name)}.{column.Name}= SQLDataServer.ExecuteSPReturnLong(\"{table.Name}Insert\", parameters, \"@{column.Name}\");");
                        classText.AppendLine("\t\t\t}");
                        classText.AppendLine("\t\t\telse");
                        classText.AppendLine("\t\t\t{");
                        classText.AppendLine($"\t\t\t\t{AddParameter(column)}");
                        classText.AppendLine($"\t\t\t\t{ExecuteSP(table.Name, "Update")}");
                        classText.AppendLine("\t\t\t}");
                    }
                }
            }

            classText.AppendLine("\t\t}");
            classText.AppendLine("\t\t#endregion");

            classText.AppendLine("");

            classText.AppendLine($"\t\t{newRegion}Deleting Items from the database");

            classText.AppendLine($"\t\tpublic void Delete({table.PrimaryKey.cSharpDataType} {Library.LowerFirstCharacter(table.Name)}Id)");
            classText.AppendLine($"\t\t{{");
            classText.AppendLine($"\t\t\tList<SqlParameter> parameters = new List<SqlParameter>();");
            classText.AppendLine("");
            classText.AppendLine($"\t\t\t{AddParameter(Library.LowerFirstCharacter(table.Name) + "Id", table.PrimaryKey)}");
            classText.AppendLine();
            classText.AppendLine($"\t\t\t{ExecuteSP(table.Name.ToString(), "Delete")}");

            classText.AppendLine($"\t\t}}");
            classText.AppendLine("");



            foreach (SQLForeignKeyRelation foreignKeyRelation in foreignKeys)
            {
                SQLTableColumn column            = foreignKeyRelation.ReferencedTableColumn;
                string         loweredColumnName = Library.LowerFirstCharacter(column.Name);

                classText.AppendLine($"\t\tpublic void DeleteBy{column.Name}({column.cSharpDataType} {loweredColumnName})");
                classText.AppendLine($"\t\t{{");
                classText.AppendLine($"\t\t\tList<SqlParameter> parameters = new List<SqlParameter>();");
                classText.AppendLine("");
                classText.AppendLine($"\t\t\t{AddParameter(loweredColumnName, column)}");
                classText.AppendLine();
                classText.AppendLine($"\t\t\t{ExecuteSP(table.Name.ToString(), "DeleteFor" + column.TableName)}");
                classText.AppendLine($"\t\t}}");
            }


            classText.AppendLine("\t\t" + endRegion);

            classText.AppendLine("\t}"); // This is the closing of the class.
            classText.AppendLine("}");   // This is the closing of the namespace.
        }
コード例 #13
0
 private string GetLookupData(SQLTableColumn column)
 {
     return($"\t\tthis.get{column.TableName}Data();");
 }
コード例 #14
0
 private string StateLookupStorage(SQLTableColumn column)
 {
     return($"\t\t\t{Library.LowerFirstCharacter(column.TableName)}s : [],");
 }
コード例 #15
0
 private string DropdownLoadingCodeForForeignKey(SQLTableColumn column)
 {
     return($"\t\tlet {Library.LowerFirstCharacter(column.TableName)}Dropdown = this.state.loading ? <p><em>Loading</em></p> : this.Display{column.TableName}Dropdown();");
 }
コード例 #16
0
 private string CreateClassCode(SQLTableColumn column)
 {
     return($"\t\t\t{Library.LowerFirstCharacter(column.Name)}: this.state.{Library.LowerFirstCharacter(column.Name)},");
 }
コード例 #17
0
 private string CreateStateCode(SQLTableColumn column)
 {
     return($"\t\t\t{Library.LowerFirstCharacter(column.Name)}: {(column.htmlInputFormType == htmlFormValueType.text ? "''" : "null")},");
 }