Ejemplo n.º 1
0
        private static string _CreateColumnDef(IDatabaseService db, ObjectIndexMetadata indexMetadata)
        {
            string name = db.EscapeCommandText(indexMetadata.Name);
            string type = "VARCHAR";
            string length = "(30)";
            string nullable = " NOT NULL";
            if (indexMetadata.Nullable)
            {
                nullable = " NULL";
            }

            switch (indexMetadata.DataType)
            {
                case ObjectIndexType.Integer:
                    type = "INT";
                    length = "";
                    break;
                case ObjectIndexType.Binary:
                    type = "VARBINARY";
                    length = "(" + indexMetadata.Precision + ")";
                    break;
                case ObjectIndexType.DateTime:
                    type = "DATETIME";
                    length = "";
                    break;
                case ObjectIndexType.Decimal:
                    type = "DECIMAL";
                    length = "(" + indexMetadata.Precision + "," + indexMetadata.Scale + ")";
                    break;
                default:
                    length = "(" + indexMetadata.Precision + ")";
                    break;
            }

            return string.Format("`{0}` {1}{2} {3}", name, type, length, nullable);
        }
Ejemplo n.º 2
0
 private static string _CreateTableName(IDatabaseService db, string objectFullName)
 {
     return db.EscapeCommandText(objectFullName.Replace('.', '_'));
 }
Ejemplo n.º 3
0
        private static string _CreateColumnDef(IDatabaseService db, ObjectIndexMetadata indexMetadata)
        {
            string name = db.EscapeCommandText(indexMetadata.Name);
            string type = "nvarchar";
            string length = "(30)";
            string nullable = (indexMetadata.Nullable) ? "NULL" : "NOT NULL";

            switch (indexMetadata.DataType)
            {
                case ObjectIndexType.Integer:
                    type = "int";
                    length = "";
                    break;
                case ObjectIndexType.Binary:
                    type = "varbinary";
                    length = "(" + indexMetadata.Precision + ")";
                    break;
                case ObjectIndexType.DateTime:
                    type = "datetime";
                    length = "";
                    break;
                case ObjectIndexType.Decimal:
                    type = "decimal";
                    length = "(" + indexMetadata.Precision + "," + indexMetadata.Scale + ")";
                    break;
                default:
                    length = "(" + indexMetadata.Precision + ")";
                    break;
            }

            return string.Format("[{0}] [{1}]{2} {3}", name, type, length, nullable);
        }