Exemplo n.º 1
0
        /// <summary>
        /// There are two general ways to use select()-step.
        /// Select labeled steps within a path (as defined by as() in a traversal).
        /// Select objects out of a Map&lt;String,Object&gt; flow (i.e. a sub-map).
        /// When the set of keys or values (i.e. columns) of a path or map are needed, use select(keys)
        /// and select(values), respectively. select() can also accept a traversal that emits a key
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="pop"></param>
        /// <param name="traversal"></param>
        /// <returns></returns>
        public static GremlinQueryBuilder Select(this GremlinQueryBuilder builder, GremlinPopModifier pop, GremlinQueryBuilder traversal)
        {
            if (pop == null)
            {
                throw new ArgumentNullException(nameof(pop));
            }
            if (traversal == null)
            {
                throw new ArgumentNullException(nameof(traversal));
            }

            builder.AddArguments(traversal.GremlinArguments);
            return(builder.Add($"select({pop.QueryStringValue},{builder.Query})"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// There are two general ways to use select()-step.
        /// Select labeled steps within a path (as defined by as() in a traversal).
        /// Select objects out of a Map&lt;String,Object&gt; flow (i.e. a sub-map).
        /// When the set of keys or values (i.e. columns) of a path or map are needed, use select(keys)
        /// and select(values), respectively. select() can also accept a traversal that emits a key
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="pop"></param>
        /// <param name="label"></param>
        /// <returns></returns>
        public static GremlinQueryBuilder Select(this GremlinQueryBuilder builder, GremlinPopModifier pop, IGremlinParameter label)
        {
            if (pop == null)
            {
                throw new ArgumentNullException(nameof(pop));
            }
            if (label == null)
            {
                throw new ArgumentNullException(nameof(label));
            }
            if (!(label.TrueValue is string))
            {
                throw new GremlinQueryBuilderException($"{nameof(Select)} only allows strings in " +
                                                       $"{nameof(label)} parameter and {label.TrueValue} " +
                                                       $"does not appear to be");
            }

            builder.AddArgument(label as GremlinArgument);
            return(builder.Add($"select({pop.QueryStringValue},{label.QueryStringValue})"));
        }