public void CreateIndex() { StringBuilder optAttribute = new StringBuilder(); if (_indexAttributes.IsUnique) { optAttribute.AppendFormat("{0} ", UniqueKwd); } if (_indexAttributes.IsClustered) { optAttribute.AppendFormat("{0} ", ClusteredKwd); } string columnList = ListFormatter.ToString(_indexAttributes.IndexColumns, ", ", ColNameFmt); string createIndexDDL = string.Format(CreateIndexSqlFmt, optAttribute.ToString(), _indexAttributes.IndexName, _indexAttributes.TableName, columnList); using (SqlCommand cmd = new SqlCommand(createIndexDDL, _connection)) { cmd.ExecuteNonQuery(); } }
public static void GetCreateValueExpression(object value, ClrSimpleTypeInfo typeDef, CodeExpressionCollection collection) { if (value == null) { collection.Add(new CodePrimitiveExpression(value)); return; } switch (typeDef.Variety) { case XmlSchemaDatatypeVariety.List: string str = ListFormatter.ToString(value); collection.Add(new CodePrimitiveExpression(str)); break; case XmlSchemaDatatypeVariety.Atomic: if (value is string) { collection.Add(new CodePrimitiveExpression(value)); } else { collection.Add(CreateTypedValueExpression(typeDef.InnerType.Datatype, value)); } break; case XmlSchemaDatatypeVariety.Union: GetCreateUnionValueExpression(value, typeDef as UnionSimpleTypeInfo, collection); break; default: break; } }