Esempio n. 1
0
        public UniqueIndex AddUniqueIndex(ITable table, IColumn[] columns)
        {
            var index = new UniqueIndex(table, columns);

            AddIndex(index);
            return(index);
        }
Esempio n. 2
0
        public UniqueIndex AddUniqueIndex(ITable table, Field[] fields)
        {
            var index = new UniqueIndex(table, Index.GetColumnsFromFields(fields));

            AddIndex(index);
            return(index);
        }
Esempio n. 3
0
        public virtual UniqueIndex GenerateUniqueIndex(ITable table, UniqueIndexAttribute attribute)
        {
            if (attribute == null)
            {
                return(null);
            }

            var result = new UniqueIndex(table, Index.GetColumnsFromFields(this))
            {
                AvoidAttachToUniqueIndexes = attribute.AvoidAttachToUniqueIndexes
            };

            if (attribute.AllowMultipleNulls)
            {
                result.Where = IndexWhereExpressionVisitor.IsNull(this, false);
            }

            return(result);
        }
Esempio n. 4
0
 public virtual IEnumerable<Index> GeneratIndexes(ITable table)
 {
     switch (IndexType)
     {
         case IndexType.None: return Enumerable.Empty<Index>();
         case IndexType.Unique: return new[] { new UniqueIndex(table, Index.GetColumnsFromFields(this)) };
         case IndexType.UniqueMultipleNulls:
             var index = new UniqueIndex(table, Index.GetColumnsFromFields(this));
             index.Where = IndexWhereExpressionVisitor.IsNull(this, false);
             return new[] { index };
     }
     throw new InvalidOperationException("IndexType {0} not expected".Formato(IndexType));
 }
Esempio n. 5
0
        public virtual UniqueIndex GenerateUniqueIndex(ITable table, UniqueIndexAttribute attribute)
        {
            if (attribute == null)
                return null;

            var result = new UniqueIndex(table, Index.GetColumnsFromFields(this)) 
            { 
                AvoidAttachToUniqueIndexes = attribute.AvoidAttachToUniqueIndexes 
            }; 

            if(attribute.AllowMultipleNulls)
                result.Where = IndexWhereExpressionVisitor.IsNull(this, false);

            return result;
        }
Esempio n. 6
0
 public static SqlPreCommand DropIndex(UniqueIndex ix)
 {
     if (ix.ViewName == null)
         return DropIndex(ix.Table.Name, ix.IndexName);
     else
         return DropViewIndex(new ObjectName(ix.Table.Name.Schema, ix.ViewName), ix.IndexName);
 }