コード例 #1
0
        private void Where(Expression expression)
        {
            if (_where != null)
            {
                throw new InvalidOperationException("Cannot have multiple Where calls in TimeSeries functions ");
            }

            if (!(expression is UnaryExpression unary &&
                  unary.Operand is LambdaExpression lambda))
            {
                throw new NotSupportedException("Unsupported expression in Where clause " + expression);
            }

            _whereVisitor = new TimeSeriesWhereClauseVisitor <T>(lambda.Parameters[0].Name, _providerProcessor.DocumentQuery);

            if (lambda.Parameters.Count == 2) // Where((ts, tag) => ...)
            {
                LoadByTag(lambda.Parameters[1].Name);
            }

            if (lambda.Body is BinaryExpression be)
            {
                WhereBinary(be);
            }
            else if (lambda.Body is MethodCallExpression call)
            {
                WhereMethod(call);
            }
            else
            {
                throw new NotSupportedException("Unsupported expression in Where clause " + expression);
            }
        }
コード例 #2
0
        private void Where(Expression expression)
        {
            if (_where != null)
            {
                throw new InvalidOperationException("Cannot have multiple Where calls in TimeSeries functions ");
            }

            if (!(expression is UnaryExpression unary &&
                  unary.Operand is LambdaExpression lambda))
            {
                throw new NotSupportedException("Unsupported expression in Where clause " + expression);
            }

            _whereVisitor = new TimeSeriesWhereClauseVisitor <T>(lambda.Parameters[0].Name, _documentQuery);

            if (lambda.Parameters.Count == 2) // Where((ts, tag) => ...)
            {
                if (_loadTagAlias != null)    // alias is already taken by 'group by tag' and we need to use the same one
                {
                    _whereVisitor.Rename(lambda.Parameters[1].Name, _loadTagAlias);
                }

                LoadByTag(lambda.Parameters[1].Name);
            }

            if (lambda.Body is BinaryExpression be)
            {
                WhereBinary(be);
            }
            else if (lambda.Body is MethodCallExpression call)
            {
                WhereMethod(call);
            }
            else
            {
                throw new NotSupportedException("Unsupported expression in Where clause " + expression);
            }
        }