예제 #1
0
        public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
        {
            bool status = true;

            status &= _where.AppendExpression(ref exp, graph, info, selection);
            return(status);
        }
        public virtual bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
        {
            bool status = true;

            if (info.Fields is BqlCommand.EqualityList list)
            {
                list.NonStrict = true;
            }

            SQLExpression opUser = null;

            if (!typeof(IBqlCreator).IsAssignableFrom(typeof(OperandUser)))
            {
                if (info.BuildExpression)
                {
                    opUser = BqlCommand.GetSingleExpression(typeof(OperandUser), graph, info.Tables, selection, BqlCommand.FieldPlace.Condition);
                }
                info.Fields?.Add(typeof(OperandUser));
            }
            else
            {
                if (_operandUser == null)
                {
                    _operandUser = _operandUser.createOperand <OperandUser>();
                }
                status &= _operandUser.AppendExpression(ref opUser, graph, info, selection);
            }

            Query qin = new Query();

            qin[typeof(EPCompanyTreeH.workGroupID)].From(typeof(EPCompanyTreeH))
            .Join(typeof(EPCompanyTreeMember))
            .On(SQLExpression.EQ(typeof(EPCompanyTreeH.parentWGID), typeof(EPCompanyTreeMember.workGroupID))
                //.And(Column.SQLColumn(typeof(EPCompanyTreeH.parentWGID)).NotEqual(Column.SQLColumn(typeof(EPCompanyTreeH.workGroupID)))
                .And(Column.SQLColumn(typeof(EPCompanyTreeMember.active)).EQ(1))
                .And(Column.SQLColumn(typeof(EPCompanyTreeMember.userID)).EQ(opUser)))
            //)
            .Where(new SQLConst(1).EQ(1));

            Query qout = new Query();

            //Append Tail removes main object, so we fieldNote will not be mapped. Skipping conditions for AppendTail
            if (info.Tables == null || info.Tables.Count <= 0 || info.Tables.Contains(BqlCommand.GetItemType <FieldNote>()))
            {
                qout[typeof(EntityWorkgroup.refNoteID)].From(typeof(EntityWorkgroup))
                .Where(Column.SQLColumn(typeof(EntityWorkgroup.workGroupID)).In(qin)
                       .And(SQLExpression.EQ(typeof(EntityWorkgroup.refNoteID), typeof(FieldNote))));
            }
            else
            {
                qout[typeof(EntityWorkgroup.refNoteID)].From(typeof(EntityWorkgroup))
                .Where(Column.SQLColumn(typeof(EntityWorkgroup.workGroupID)).In(qin));
            }

            qout.Limit(-1);             // prevent limiting of IN subqueries
            exp = exp.In(qout);

            return(status);
        }
 public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
 => exists.AppendExpression(ref exp, graph, info, selection);