Recognized Where-Expressions
This page catalogues all kinds of lambda expressions supported by ExRam.Gremlinq in various Where-operators.
Basic predicates
Property equality & inequality
Compare a property to a constant value.
Comparison operators
Standard relational operators on properties.
Null checks
Check whether a property is or isn't null.
Boolean properties
Direct boolean property evaluation, including negation.
Constant boolean expressions
Use a literal or captured boolean variable.
Logical operators
Logical AND (&&)
Combine multiple conditions with logical AND.
Logical OR (||)
Combine multiple conditions with logical OR.
Mixed AND / OR with grouping
Parenthesised sub-expressions mixing && and ||.
Collection predicates
Collection .Contains() (value in collection)
Check whether a property value is contained in an in-memory collection.
.Where(p => new[] { 36, 37, 38 }.Contains(p.Age))
.Where(p => new List<int> { 36, 37, 38 }.Contains(p.Age))
.Where(p => someEnumerable.Contains(p.Age))
Negated:
Array / collection property .Contains()
Check whether an array property on the element contains a specific value.
Array / collection property .Any()
Test whether an array property has any elements.
Array / collection property .Length
Compare the length of an array property.
Set intersection (.Intersect().Any())
Check whether two collections share any common element, in either direction.
.Where(p => p.PhoneNumbers!.Intersect(new[] { "+4912345", "+4923456" }).Any())
.Where(p => new[] { "+4912345", "+4923456" }.Intersect(p.PhoneNumbers!).Any())
Negated:
String predicates
string.StartsWith
Match a string prefix, optionally case-insensitive or with a char.
string.EndsWith
Match a string suffix, optionally case-insensitive.
string.Contains
Check for a substring, optionally case-insensitive.
string.Equals with StringComparison
Explicit string equality with a comparison mode.
Reversed string matching (constant on the left)
The constant is on the left and the property is the argument — used for prefix-of or superstring-of semantics.
.Where(p => "+49123".StartsWith(p.CountryCallingCode!))
.Where(p => "+49123".StartsWith(p.CountryCallingCode!, StringComparison.OrdinalIgnoreCase))
.Where(p => someString.StartsWith(p.CountryCallingCode!))
.Where(p => "+49123".Contains(p.CountryCallingCode!))
Also works with sub-expressions on the left-hand side:
string.CompareTo
Lexicographic comparison via CompareTo. All comparison operators against the CompareTo return value are supported.
.Where(p => p.Name!.Value.CompareTo("Some name") == 0) // equals
.Where(p => p.Name!.Value.CompareTo("Some name") > 0) // greater
.Where(p => p.Name!.Value.CompareTo("Some name") < 0) // less
.Where(p => p.Name!.Value.CompareTo("Some name") >= 0) // greater or equal
.Where(p => p.Name!.Value.CompareTo("Some name") <= 0) // less or equal
.Where(p => p.Name!.Value.CompareTo("Some name") != 0) // not equal
Also works through the IComparable<T> interface:
.ToString() on a property
Call ToString() on a property and compare the result.
Advanced predicates
Property-to-property comparisons
Compare two properties on the same element.
Id comparisons & cast expressions
Compare the element Id, including explicit casts.
DateTime / DateTimeOffset comparisons
Compare date-typed properties to DateTime or DateTimeOffset values.
.Where(p => p.RegistrationDate!.Value == dateTime)
.Where(p => p.RegistrationDate!.Value == DateTime.MinValue)
.Where(p => p.Properties!.ValidFrom == new DateTimeOffset(2019, 1, 1, 1, 0, 0, TimeSpan.Zero))
.Where(p => p.Properties!.ValidFrom >= new DateTimeOffset(2019, 1, 1, 1, 0, 0, TimeSpan.Zero))
Captured variables & closures
Reference local variables, parameters, or expressions computed outside the lambda.
Anonymous-object property in closure
Use a property from a captured anonymous object as the boolean predicate.
StepLabel / cross-traversal references
Compare properties against values captured earlier in the traversal via step labels (.As() / StepLabel).
Sub-traversals in Where
Use a nested anonymous traversal as a filter predicate.
Nested Where on sub-traversals (value filtering)
Apply Where inside a sub-traversal to filter by traversed values.
Null / AND / OR on value-type sub-traversals
Null checks, AND, and OR on scalar sub-traversal results.
VertexProperty metadata access
Filter on VertexProperty key, label, value, or meta-properties.
.Values() sub-traversal in Where
Project a property inside a filter to assert its existence or shape.
Projected tuple element access
After a .Project().ToTuple().By(...) projection, the traversal yields tuples. Where can filter on individual elements of these tuples via .Item1, .Item2, etc.
_g
.Inject(42)
.Project(__ => __
.ToTuple()
.By(__ => __.Constant("item1"))
.By(__ => __.Fold()))
.Where(x => x.Item2.Length == 3)
In this example, Item2 refers to the second projected column (the result of .Fold(), which is an array). The .Length comparison is an array-length filter applied to that specific tuple element.