Пример #1
0
        public TableIndex AddIndex <T>(Expression <Func <T, object?> > fields,
                                       Expression <Func <T, bool> >?where           = null,
                                       Expression <Func <T, object> >?includeFields = null) where T : Entity
        {
            var table = Schema.Table <T>();

            IColumn[] columns = IndexKeyColumns.Split(table, fields);

            var index = new TableIndex(table, columns);

            if (where != null)
            {
                index.Where = IndexWhereExpressionVisitor.GetIndexWhere(where, table);
            }

            if (includeFields != null)
            {
                index.IncludeColumns = IndexKeyColumns.Split(table, includeFields);
                if (table.SystemVersioned != null)
                {
                    index.IncludeColumns = index.IncludeColumns.Concat(table.SystemVersioned.Columns()).ToArray();
                }
            }

            AddIndex(index);

            return(index);
        }
Пример #2
0
        public TableIndex AddIndexMList <T, V>(Expression <Func <T, MList <V> > > toMList,
                                               Expression <Func <MListElement <T, V>, object> > fields,
                                               Expression <Func <MListElement <T, V>, bool> >?where           = null,
                                               Expression <Func <MListElement <T, V>, object> >?includeFields = null)
            where T : Entity
        {
            TableMList table = ((FieldMList)Schema.FindField(Schema.Table(typeof(T)), Reflector.GetMemberList(toMList))).TableMList;

            IColumn[] columns = IndexKeyColumns.Split(table, fields);

            var index = AddIndex(table, columns);

            if (where != null)
            {
                index.Where = IndexWhereExpressionVisitor.GetIndexWhere(where, table);
            }

            if (includeFields != null)
            {
                index.IncludeColumns = IndexKeyColumns.Split(table, includeFields);
                if (table.SystemVersioned != null)
                {
                    index.IncludeColumns = index.IncludeColumns.Concat(table.SystemVersioned.Columns()).ToArray();
                }
            }

            return(index);
        }
Пример #3
0
        public UniqueIndex AddUniqueIndex <T>(Expression <Func <T, object> > fields, Expression <Func <T, bool> > where = null) where T : Entity
        {
            var table = Schema.Table <T>();

            IColumn[] columns = IndexKeyColumns.Split(table, fields);

            var index = AddUniqueIndex(table, columns);

            if (where != null)
            {
                index.Where = IndexWhereExpressionVisitor.GetIndexWhere(where, table);
            }

            return(index);
        }
Пример #4
0
        public UniqueIndex AddUniqueIndexMList <T, V>(Expression <Func <T, MList <V> > > toMList, Expression <Func <MListElement <T, V>, object> > fields, Expression <Func <MListElement <T, V>, bool> > where)
            where T : Entity
        {
            TableMList table = ((FieldMList)Schema.FindField(Schema.Table(typeof(T)), Reflector.GetMemberList(toMList))).TableMList;

            IColumn[] columns = IndexKeyColumns.Split(table, fields);

            var index = AddUniqueIndex(table, columns);

            if (where != null)
            {
                index.Where = IndexWhereExpressionVisitor.GetIndexWhere(where, table);
            }

            return(index);
        }
Пример #5
0
        public Index AddIndex <T>(Expression <Func <T, object> > fields, Expression <Func <T, bool> > where = null, Expression <Func <T, object> > includeFields = null) where T : Entity
        {
            var table = Schema.Table <T>();

            IColumn[] columns = IndexKeyColumns.Split(table, fields);

            var index = new Index(table, columns);

            if (where != null)
            {
                index.Where = IndexWhereExpressionVisitor.GetIndexWhere(where, table);
            }

            if (includeFields != null)
            {
                index.IncludeColumns = IndexKeyColumns.Split(table, includeFields);
            }

            AddIndex(index);

            return(index);
        }