Пример #1
0
        public static IndexDefinition GetIndexDefinition(Type modelType, PropertyInfo propertyInfo, IndexAttribute attribute, string columnName, string tableName)
        {
            string indexName = string.IsNullOrEmpty(attribute.Name)
                                   ? string.Format("IX_{0}_{1}", tableName, columnName)
                                   : attribute.Name;

            var definition = new IndexDefinition
                                 {
                                     Name = indexName,
                                     IndexType = attribute.IndexType,
                                     ColumnName = columnName,
                                     TableName = tableName,
                                     IsClustered = attribute.IndexType == IndexTypes.Clustered,
                                     IsUnique = attribute.IndexType == IndexTypes.UniqueNonClustered
                                 };

            if (string.IsNullOrEmpty(attribute.ForColumns) == false)
            {
                var columns = attribute.ForColumns.Split(',').Select(p => p.Trim());
                foreach (var column in columns)
                {
                    definition.Columns.Add(new IndexColumnDefinition {Name = column, Direction = Direction.Ascending});
                }
            }
            return definition;
        }
 public CreateIndexExpression(DatabaseProviders current, DatabaseProviders[] databaseProviders) : base(current, databaseProviders)
 {
     Index = new IndexDefinition();
 }
 public CreateIndexExpression()
 {
     Index = new IndexDefinition();
 }
 public DeleteIndexExpression()
 {
     Index = new IndexDefinition();
 }