コード例 #1
0
        public UniqueTableIndex AddUniqueIndexMList <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 = AddUniqueIndex(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);
        }
コード例 #2
0
        static IColumn[] GetColumns(IFieldFinder finder, LambdaExpression field)
        {
            var body = field.Body;

            Type?type = RemoveCasting(ref body);

            body = IndexWhereExpressionVisitor.RemoveLiteEntity(body);

            var members = Reflector.GetMemberListBase(body);

            if (members.Any(a => ignoreMembers.Contains(a.Name)))
            {
                members = members.Where(a => !ignoreMembers.Contains(a.Name)).ToArray();
            }

            Field f = Schema.FindField(finder, members);

            if (type != null)
            {
                var ib = f as FieldImplementedBy;
                if (ib == null)
                {
                    throw new InvalidOperationException("Casting only supported for {0}".FormatWith(typeof(FieldImplementedBy).Name));
                }

                return((from ic in ib.ImplementationColumns
                        where type.IsAssignableFrom(ic.Key)
                        select(IColumn) ic.Value).ToArray());
            }

            return(TableIndex.GetColumnsFromFields(f));
        }
コード例 #3
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 = Split(table, fields);

            var index = AddUniqueIndex(table, columns);

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

            return(index);
        }
コード例 #4
0
        public Field GetField(Expression exp)
        {
            if (exp.NodeType == ExpressionType.Convert)
            {
                exp = ((UnaryExpression)exp).Operand;
            }

            return(Schema.FindField(RootFinder, Reflector.GetMemberListBase(exp)));
        }