Example #1
0
        public static IIndexConfig Index(this ITableConfig table, IEnumerable <IColumnConfig> columns, IndexFlags?flags = null)
        {
            var selector = IndexConfig.By(columns, flags);
            var index    = table.GetIndex(selector);

            if (index == null)
            {
                index = table.CreateIndex(selector);
            }
            return(index);
        }
Example #2
0
        public void Configure(IConfig config, ITableConfig table)
        {
            var index = table.GetIndex(IndexConfig.By(new[] { "Field1", "Field2", "Field3" }));

            if (index != null)
            {
                index.Expression = index.Expression.Combine(
                    QueryOperator.AndAlso,
                    index.Columns.Select(column => index.CreateConstraint().With(expression =>
                {
                    expression.Left     = expression.CreateColumn(column);
                    expression.Operator = expression.CreateOperator(QueryOperator.Is);
                    expression.Right    = expression.CreateUnary(QueryOperator.Not, expression.CreateOperator(QueryOperator.Null));
                })).ToArray()
                    );
            }
        }