public static GremlinScript In(this GremlinScript query, params string[] relationshipName) { if (relationshipName.Count() == 1) { return(query.Append(".in({0})", relationshipName[0])); } // Can not send more then one element via parameters var relationships = relationshipName.Aggregate(new StringBuilder(), (sb, item) => sb.AppendFormat("{1}'{0}'", item, sb.Length == 0 ? string.Empty : ",")); return(query.Append(string.Format(".in({0})", relationships))); }
public void FilterClause() { GremlinScript script = new GremlinScript(); script.Append("g.v(0)") .Filter(it => it.GetProperty("MyProp") == "SomeValue"); Assert.IsTrue(script.ToString() == "g.v(0).filter{it.getProperty('MyProp') == 'SomeValue'}"); }
public void FilterClauseCompareToIgnoreCase2() { GremlinScript script = new GremlinScript(); script.Append("g.v(0)") .Filter(it => it.GetProperty("MyProp").CompareToIgnoreCase(it.GetProperty("CompareProperty").Name())); Assert.IsTrue(script.ToString() == "g.v(0).filter{it.getProperty('MyProp').compareToIgnoreCase(it.getProperty('CompareProperty').name)}"); }
public void FilterClauseChainCommands() { GremlinScript script = new GremlinScript(); script.Append("g.v(0)") .Filter(it => it.GetProperty("MyProp").ToLowerCase().Contains("ContainThis")); Assert.IsTrue(script.ToString() == "g.v(0).filter{it.getProperty('MyProp').toLowerCase().contains('ContainThis')}"); }
public static GremlinScript RelationshipIndexLookup(this GremlinScript query, IEnumerable <KeyValuePair <string, string> > propertyKeyValue) { var sb = new StringBuilder(); foreach (var kvp in propertyKeyValue) { sb.AppendFormat("{0}'{1}':'{2}'", sb.Length > 0 ? "," : "", kvp.Key, kvp.Value); } return(query.Append("g.E[[{0}]]", sb.ToString())); }
public static GremlinScript NodeIndexLookup(this GremlinScript query, IEnumerable <KeyValuePair <string, object> > propertyKeyValue) { var sb = new StringBuilder(); foreach (var kvp in propertyKeyValue) { if (kvp.Value is string) { sb.AppendFormat("{0}'{1}':'{2}'", sb.Length > 0 ? "," : "", kvp.Key, kvp.Value); } else if (kvp.Value is bool) { sb.AppendFormat("{0}'{1}':{2}", sb.Length > 0 ? "," : "", kvp.Key, (bool)kvp.Value ? "true" : "false"); } else { sb.AppendFormat("{0}'{1}':{2}", sb.Length > 0 ? "," : "", kvp.Key, kvp.Value); } } return(query.Append("g.V[[{0}]]", sb.ToString())); }
public static GremlinScript Retain(this GremlinScript query, string variable) { return(query.Append(".retain({0})", variable)); }
public static GremlinScript Unique(this GremlinScript query) { return(query.Append(".unique()")); }
public static GremlinScript BothV(this GremlinScript query) { return(query.Append(".bothV()")); }
public static GremlinScript Except(this GremlinScript query, string variable) { return(query.Append(".except({0})", variable)); }
public static GremlinScript gE(this GremlinScript query, IEnumerable <long> Ids) { return(query.Append("g.e({0})", string.Join(",", Ids))); }
public static GremlinScript Back(this GremlinScript query, int steps) { return(query.Append(string.Format(".back({0})", steps))); }
public static GremlinScript Table(this GremlinScript query, string name, params string[] columnNames) { string names = string.Join(",", columnNames.Select(r => string.Concat("'", r, "'"))); return(query.Append(string.Format(".table({0}, [{1}])", name, names))); }
public static GremlinScript NewArray(this GremlinScript query, string name) { return(query.Append(string.Format("{0} = [];", name))); }
public static GremlinScript Each(this GremlinScript query, string each, params object[] args) { return(query.Append(string.Format(".each{{{0}}}", string.Format(each, args)))); }
public static GremlinScript BothV(this GremlinScript query, params string[] relationshipName) { return(query.Append(".bothV({0})", string.Join(",", relationshipName))); }
public static GremlinScript Reverse(this GremlinScript query) { return(query.Append(".reverse()")); }
public static GremlinScript Sort(this GremlinScript query, Expression <Func <JavaObject, object> > func) { return(query.Append(string.Format(".sort{{{0}}}", new ParseJavaLambda().Parse(func)), false)); }
public static GremlinScript Sort(this GremlinScript query, string sort, params object[] args) { return(query.Append(string.Format(".sort({{{0}}})", string.Format(sort, args)), false)); }
public static GremlinScript Filter(this GremlinScript query, string filter, params object[] args) { return(query.Append(string.Format(".filter{{{0}}}", string.Format(filter, args)))); }
public static GremlinScript Filter(this GremlinScript query, string filter) { return(query.Append(string.Format(".filter{{{0}}}", filter), false)); }
public static GremlinScript Table(this GremlinScript query, string name) { return(query.Append(string.Format(".table({0})", name))); }
public static GremlinScript ToList(this GremlinScript query) { return(query.Append(".toList()")); }
public static GremlinScript NewTable(this GremlinScript query, string name) { return(query.Append(string.Format("{0} = new Table();", name))); }
public static GremlinScript ToPipe(this GremlinScript query) { return(query.Append("._()")); }
public static GremlinScript gE(this GremlinScript query, long Id) { return(query.Append("g.e({0})", Id)); }
public void FilterClauseCompound() { GremlinScript script = new GremlinScript(); script.Append("g.v(0)") .Filter(it => it.GetProperty("MyProp") && !it.GetProperty("NotProp") || it.GetProperty("OrProp").ToLowerCase() == "lower Value"); Assert.IsTrue(script.ToString() == "g.v(0).filter{it.getProperty('MyProp') && !it.getProperty('NotProp') || it.getProperty('OrProp').toLowerCase() == 'lower Value'}"); }
public static GremlinScript In(this GremlinScript query) { return(query.Append(".in()")); }
public static GremlinScript Back(this GremlinScript query, string label) { return(query.Append(string.Format(".back('{0}')", label))); }
public static GremlinScript Array <T>(this GremlinScript query, params T[] items) { return(query.Append(string.Format("[{0}]", items.Aggregate(new StringBuilder(), (sb, item) => sb.AppendFormat("{1}{2}{0}{2}", item, sb.Length > 0 ? "," : string.Empty, typeof(T) == typeof(string) ? "'" : string.Empty))))); }
public static GremlinScript g(this GremlinScript query, IEnumerable <Relationship> relationships) { return(query.Append("g.e({0})", string.Join(",", relationships.Select(s => s.Id).ToArray()))); }
public static GremlinScript As(this GremlinScript query, string label) { return(query.Append(".as({0})", label)); }
public static GremlinScript Aggregate(this GremlinScript query, string variable) { return(query.Append(".aggregate({0})", variable)); }
public void FilterClauseEqualBool() { GremlinScript script = new GremlinScript(); script.Append("g.v(0)") .Filter(it => it.GetProperty("MyProp") == true); Assert.IsTrue(script.ToString() == "g.v(0).filter{it.getProperty('MyProp') == true}"); }
public static GremlinScript g(this GremlinScript query, Relationship relationship) { return(query.Append("g.e({0})", relationship.Id)); }