示例#1
0
        public UniqueIndex AddUniqueIndex(ITable table, IColumn[] columns)
        {
            var index = new UniqueIndex(table, columns);

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

            AddIndex(index);
            return(index);
        }
示例#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);
        }
示例#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));
 }
示例#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;
        }
示例#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);
 }