Пример #1
0
        public List<string> GenerateCreateIndexStatement(CreateIndex statement)
        {
            StringBuilder columnList = new StringBuilder();
             foreach (CreateIndex.Column col in statement.Columns)
             {
            if (columnList.Length > 0)
               columnList.Append(", ");

            columnList.Append(col.Name);
            if (col.MaxLength > 0)
            {
               columnList.AppendFormat("({0})", col.MaxLength);
            }
             }

             /*
            CREATE INDEX idx_greylisting_triplets ON hm_greylisting_triplets (glipaddress, glsenderaddress, glrecipientaddress);
              */
             StringBuilder sb = new StringBuilder();
             sb.AppendFormat("CREATE {0} INDEX {1} ON {2} ({3})",
            statement.Unique ? "UNIQUE" : "",
            statement.Name,
            statement.Table,
            columnList.ToString());

             return new List<string>() { sb.ToString() };
        }
Пример #2
0
        public List<string> GenerateCreateIndexStatement(CreateIndex statement)
        {
            StringBuilder columnList = new StringBuilder();
             foreach (CreateIndex.Column col in statement.Columns)
             {
            if (columnList.Length > 0)
               columnList.Append(", ");

            columnList.Append(col.Name);
             }

             /*
            ALTER TABLE hm_accounts ADD CONSTRAINT test1 UNIQUE NONCLUSTERED (accountid)

            Clustered indexes are not supported in SQL CE.
              */
             StringBuilder sb = new StringBuilder();
             sb.AppendFormat("CREATE {0} NONCLUSTERED INDEX {1} ON {2} ({3})",
            statement.Unique ? "UNIQUE" : "",
            statement.Name,
            statement.Table,
            columnList.ToString());

             return new List<string>() { sb.ToString() };
        }
Пример #3
0
        private IStatement ParseCreateIndexStatement(XmlNode statement)
        {
            CreateIndex createIndexStatement = new CreateIndex();
             createIndexStatement.Name = statement.Attributes["Name"].Value;
             createIndexStatement.Table = statement.Attributes["Table"].Value;
             createIndexStatement.Unique = Convert.ToBoolean(statement.Attributes["Unique"].Value);
             createIndexStatement.Clustered = Convert.ToBoolean(statement.Attributes["Clustered"].Value);

             foreach (XmlNode childNode in statement.ChildNodes)
             {
            if (!(statement is System.Xml.XmlElement))
               continue;

            CreateIndex.Column col = new CreateIndex.Column();
            col.Name = childNode.Attributes["Name"].Value;

            XmlAttribute attribute = childNode.Attributes["MaxLength"];
            if (attribute != null)
               col.MaxLength = Convert.ToInt32(attribute.Value.Length);

            createIndexStatement.Columns.Add(col);
             }

             return createIndexStatement;
        }