public UniqueIndex AddUniqueIndex(ITable table, IColumn[] columns) { var index = new UniqueIndex(table, columns); AddIndex(index); return(index); }
public UniqueIndex AddUniqueIndex(ITable table, Field[] fields) { var index = new UniqueIndex(table, Index.GetColumnsFromFields(fields)); AddIndex(index); return(index); }
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); }
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)); }
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; }
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); }