Пример #1
0
        public static string CRUDParams(SqlNames Property, bool enableComa)
        {
            var result = "";

            result += "@" + Property.COLUMN_NAME + " " + DataTypeDeclare(Property, Property.DATA_TYPE) + (enableComa ? " ," : "") + Enter;

            return(result);
        }
Пример #2
0
        public static string CreateSample(SqlNames Property, bool enableComa)
        {
            var result = "";

            result += "[" + Property.COLUMN_NAME + "] " + DataTypeDeclare(Property, Property.DATA_TYPE) + " " + (enableComa ? "," : "") + Enter;

            return(result);
        }
Пример #3
0
        public static string ConditionFilters(SqlNames Property, bool enableComa)
        {
            var result = "";

            if (MinMaxDataTypes(Property.DATA_TYPE))
            {
                result += Enter + "@" + Property.COLUMN_NAME + " " + DataTypeDeclare(Property, Property.DATA_TYPE) + " = NULL ," + Enter;
                result += "@MultiText_" + Property.COLUMN_NAME + " nvarchar(MAX) = '' ," + Enter;
                result += "@Min" + Property.COLUMN_NAME + " " + DataTypeDeclare(Property, Property.DATA_TYPE) + " = NULL ," + Enter;
                result += "@Max" + Property.COLUMN_NAME + " " + DataTypeDeclare(Property, Property.DATA_TYPE) + (enableComa ? " = NULL ," : " = NULL") + Enter + Enter;
            }
            else
            {
                result += Enter + "@" + Property.COLUMN_NAME + " " + DataTypeDeclare(Property, Property.DATA_TYPE) + " = NULL ," + Enter;
                result += "@MultiText_" + Property.COLUMN_NAME + " nvarchar(MAX) = '' " + (enableComa ? "," : "") + Enter + Enter;
            }

            return(result);
        }
Пример #4
0
        public static string ConditionStatement(SqlNames Property, bool enableComa, string constName)
        {
            var result = "-- || Auto Generated Conditions || --" + Enter;
            var readSelectTemplateMinMax = System.IO.File.ReadAllText("sqlTemplates\\minMaxConditionsTemplate.txt");
            var readSelectTemplateSimple = System.IO.File.ReadAllText("sqlTemplates\\simpleConditionsTemplate.txt");
            var readSelectTemplateChar   = System.IO.File.ReadAllText("sqlTemplates\\charConditionTemplate.txt");

            if (MinMaxDataTypes(Property.DATA_TYPE))
            {
                result +=
                    readSelectTemplateMinMax.
                    Replace("#COLNAME#", Property.COLUMN_NAME).
                    Replace("#CONST#", constName).
                    Replace("#AND#", (enableComa ? "And" : ""))
                    + Enter + Enter;
            }
            else if (!CharType(Property.DATA_TYPE))
            {
                result +=
                    readSelectTemplateSimple.
                    Replace("#COLNAME#", Property.COLUMN_NAME).
                    Replace("#CONST#", constName).
                    Replace("#AND#", (enableComa ? "And" : ""))
                    + Enter + Enter;
            }
            else
            {
                result +=
                    readSelectTemplateChar.
                    Replace("#COLNAME#", Property.COLUMN_NAME).
                    Replace("#CONST#", constName).
                    Replace("#AND#", (enableComa ? "And" : ""))
                    + Enter + Enter;
            }
            return(result);
        }
Пример #5
0
        public static string DataTypeDeclare(SqlNames Property, string type)
        {
            var result = type;

            switch (type)
            {
            case "datetime2":
            {
                result += "(" + Property.DATETIME_PRECISION + ")";
                return(result);
            }

            case "datetimeoffset":
            {
                result += "(" + Property.DATETIME_PRECISION + ")";
                return(result);
            }

            case "decimal":
            {
                //result += "(" + Property.NUMERIC_PRECISION + "," + Property.NUMERIC_SCALE + ")";
                return(result);
            }

            case "nchar":
            {
                result += "(" + Property.CHARACTER_MAXIMUM_LENGTH + ")";
                return(result);
            }

            case "numeric":
            {
                //result += "(" + Property.NUMERIC_PRECISION + "," + Property.NUMERIC_SCALE + ")";
                return(result);
            }

            case "nvarchar":
            {
                result += "(" + (Property.CHARACTER_MAXIMUM_LENGTH == -1 ? "MAX" : Property.CHARACTER_MAXIMUM_LENGTH.ToString()) + ")";
                return(result);
            }

            case "time":
            {
                result += "(" + Property.DATETIME_PRECISION + ")";
                return(result);
            }

            case "varbinary":
            {
                result += "(" + (Property.CHARACTER_MAXIMUM_LENGTH == -1 ? "MAX" : Property.CHARACTER_MAXIMUM_LENGTH.ToString()) + ")";
                return(result);
            }

            case "varchar":
            {
                result += "(" + (Property.CHARACTER_MAXIMUM_LENGTH == -1 ? "MAX" : Property.CHARACTER_MAXIMUM_LENGTH.ToString()) + ")";
                return(result);
            }

            case "binary":
            {
                result += "(" + Property.CHARACTER_OCTET_LENGTH + ")";
                return(result);
            }

            case "char":
            {
                result += "(" + Property.CHARACTER_OCTET_LENGTH + ")";
                return(result);
            }

            default:
                return(result);
            }
        }