Example #1
0
        public override Query VisitFieldExpression(CalcParser.FieldExpressionContext context)
        {
            Query     fieldQuery = Visit(context.expression());
            string    fieldName  = fieldQuery.Text;
            FieldInfo fieldInfo  = this._metadataResolver.GetField(fieldName);

            ResultType type = ResultType.Number;
            string     queryText;

            if (fieldInfo.Type != DFM_FIELD_TYPE.DFM_FT_STRING && fieldInfo.Type != DFM_FIELD_TYPE.DFM_FT_MEMO)
            {
                if (fieldInfo.Type == DFM_FIELD_TYPE.DFM_FT_DATE)
                {
                    type = ResultType.Date;
                }

                queryText = "X" + fieldInfo.Name;
            }
            else
            {
                queryText = this._dbTranslator.FieldToInt(fieldInfo);
            }

            return(new Query(queryText, type));
        }
Example #2
0
        public override Argument VisitFieldExpression(CalcParser.FieldExpressionContext context)
        {
            Argument arg = Visit(context.expression());

            if (arg.IsNull)
            {
                return(Argument.Null);
            }

            if (arg.IsDouble || arg.IsDate)
            {
                throw new ArgumentCastException("Argument of $FIELD macro should not be a number or a date");
            }

            string fieldName = arg.ToString();

            return(this._resolver.ResolveFieldValue(fieldName));
        }