/// <summary> /// Adds the "addV()" step to the traversal, creating a new vertex in the graph. /// </summary> /// <typeparam name="TVertex">The type of the vertex.</typeparam> /// <param name="traversal">The traversal.</param> /// <returns>Returns the resulting traversal</returns> public static ISchemaBoundTraversal <object, TVertex> AddV <TVertex>(this ITraversal traversal) where TVertex : IVertex { var label = LabelNameResolver.GetLabelName(typeof(TVertex)); return(traversal.AsGraphTraversal().AddV(label).AsSchemaBound <object, TVertex>()); }
/// <summary> /// Adds the "addE()" step to the traversal, creating a new edge in the graph. /// </summary> /// <typeparam name="TEdge">The type of the edge.</typeparam> /// <param name="traversal">The traversal.</param> /// <returns>Returns the resulting traversal</returns> public static ISchemaBoundTraversal <object, TEdge> AddE <TEdge>(this ITraversal traversal) where TEdge : IEdge { var label = LabelNameResolver.GetLabelName(typeof(TEdge)); return(traversal.AsGraphTraversal().AddE(label).AsSchemaBound <object, TEdge>()); }
/// <summary> /// Adds the "E().HasLabel(label_for_type_of_edge)" step to the traversal. /// </summary> /// <typeparam name="TEdge">The type of the edge.</typeparam> /// <param name="graphTraversalSource">The graph traversal source.</param> /// <param name="edgeIds">The edge id(s).</param> /// <returns>Returns the resulting traversal</returns> public static ISchemaBoundTraversal <Edge, TEdge> E <TEdge>(this IGraphTraversalSource graphTraversalSource, params object[] edgeIds) { var label = LabelNameResolver.GetLabelName(typeof(TEdge)); var traversal = graphTraversalSource.E(edgeIds).HasLabel(label); return(traversal.AsSchemaBound <Edge, TEdge>()); }
/// <summary> /// Adds the "V().HasLabel(label_for_type_of_node)" step to the traversal. /// </summary> /// <typeparam name="TVertex">The type of the vertex.</typeparam> /// <param name="graphTraversalSource">The graph traversal source.</param> /// <param name="vertexIds">The vertex id(s).</param> /// <returns>Returns the resulting traversal</returns> public static ISchemaBoundTraversal <Vertex, TVertex> V <TVertex>(this IGraphTraversalSource graphTraversalSource, params object[] vertexIds) { var label = LabelNameResolver.GetLabelName(typeof(TVertex)); var traversal = graphTraversalSource.V(vertexIds).HasLabel(label); return(traversal.AsSchemaBound <Vertex, TVertex>()); }
/// <summary> /// Adds the "addV()" step to the traversal, creating a new vertex in the graph. /// </summary> /// <typeparam name="TVertex">The type of the vertex.</typeparam> /// <param name="graphTraversalSource">The graph traversal source.</param> /// <returns>Returns the resulting traversal</returns> public static ISchemaBoundTraversal <object, TVertex> AddV <TVertex>(this IGraphTraversalSource graphTraversalSource) where TVertex : VertexBase { var label = LabelNameResolver.GetLabelName(typeof(TVertex)); return(graphTraversalSource.AddV(label).AsSchemaBound <object, TVertex>()); }
/// <summary> /// Adds the "V(["partitionKey", "id"]).HasLabel(label_for_type_of_node)" step to the traversal. /// </summary> /// <typeparam name="TVertex">The type of the vertex.</typeparam> /// <param name="graphTraversalSource">The graph traversal source.</param> /// <param name="partitionKeyIdPairs">The pair(s) of vertex partition key and id.</param> /// <returns>Returns the resulting traversal</returns> public static ISchemaBoundTraversal <Vertex, TVertex> V <TVertex>(this IGraphTraversalSource graphTraversalSource, params PartitionKeyIdPair[] partitionKeyIdPairs) { var label = LabelNameResolver.GetLabelName(typeof(TVertex)); var traversal = graphTraversalSource.V(partitionKeyIdPairs).HasLabel(label); return(traversal.AsSchemaBound <Vertex, TVertex>()); }
/// <summary> /// Adds the "outE()" step to the traversal, returning all adjacent outbound edges /// </summary> /// <typeparam name="S">The source of the traversal</typeparam> /// <typeparam name="TVertex">The type of the vertex.</typeparam> /// <typeparam name="TEdge">The type of the edge.</typeparam> /// <param name="traversal">The traversal.</param> /// <param name="edgeSelector">The edge selector.</param> /// <returns>Returns the resulting traversal</returns> public static ISchemaBoundTraversal <S, TEdge> OutE <S, TVertex, TEdge>(this ISchemaBoundTraversal <S, TVertex> traversal, Expression <Func <TVertex, TEdge> > edgeSelector) where TVertex : VertexBase where TEdge : IHasOutVertex <TVertex> { var labelName = LabelNameResolver.GetLabelName(typeof(TEdge)); return(traversal.AsGraphTraversal().OutE(labelName).AsSchemaBound <S, TEdge>()); }
/// <summary> /// Adds the "out()" step to the traversal, returning all adjacent vertices connected via outbount edges /// </summary> /// <typeparam name="S">The source of the traversal</typeparam> /// <typeparam name="TVertex">The type of the vertex.</typeparam> /// <typeparam name="TinVertex">The type of the "in"/destination vertex.</typeparam> /// <param name="traversal">The traversal.</param> /// <param name="edgeSelector">The edge selector.</param> /// <returns>Returns the resulting traversal</returns> public static ISchemaBoundTraversal <S, TinVertex> Out <S, TVertex, TinVertex>(this ISchemaBoundTraversal <S, TVertex> traversal, Expression <Func <TVertex, IEdge <TVertex, TinVertex> > > edgeSelector) where TVertex : IVertex where TinVertex : IVertex { var labelName = GetLabelName(typeof(TVertex), edgeSelector); var inVertexLabel = LabelNameResolver.GetLabelName(typeof(TinVertex)); return(traversal.AsGraphTraversal().Out(labelName).HasLabel(inVertexLabel).AsSchemaBound <S, TinVertex>()); }
/// <summary> /// Adds the "addV()" step to the traversal, creating a new vertex in the graph. /// </summary> /// <typeparam name="TEdge">The type of the edge.</typeparam> /// <param name="traversal">The graph traversal.</param> /// <param name="edge">The edge to add.</param> /// <param name="serializationSettings">The serialization settings.</param> /// <returns>Returns the resulting traversal</returns> public static ISchemaBoundTraversal <object, TEdge> AddE <TEdge>(this ITraversal traversal, TEdge edge, JsonSerializerSettings serializationSettings) where TEdge : IEdge { var label = LabelNameResolver.GetLabelName(typeof(TEdge)); var t = traversal.AsGraphTraversal().AddE(label); t = TraversalHelper.AddObjectProperties(t, edge, serializationSettings); return(t.AsSchemaBound <object, TEdge>()); }
/// <summary> /// Adds the "addV()" step to the traversal, creating a new vertex in the graph. /// </summary> /// <typeparam name="TVertex">The type of the vertex.</typeparam> /// <param name="traversal">The graph traversal.</param> /// <param name="vertex">The vertex to add.</param> /// <param name="serializationSettings">The serialization settings.</param> /// <returns>Returns the resulting traversal</returns> public static ISchemaBoundTraversal <object, TVertex> AddV <TVertex>(this ITraversal traversal, TVertex vertex, JsonSerializerSettings serializationSettings) where TVertex : IVertex { var label = LabelNameResolver.GetLabelName(typeof(TVertex)); var t = traversal.AsGraphTraversal().AddV(label); t = TraversalHelper.AddObjectProperties(t, vertex, serializationSettings); return(t.AsSchemaBound <object, TVertex>()); }
/// <summary> /// Adds the "addV()" step to the traversal, creating a new vertex in the graph. /// </summary> /// <typeparam name="TVertex">The type of the vertex.</typeparam> /// <param name="graphTraversalSource">The graph traversal source.</param> /// <param name="vertex">The vertex to add.</param> /// <param name="serializationSettings">The serialization settings.</param> /// <returns>Returns the resulting traversal</returns> public static ISchemaBoundTraversal <object, TVertex> AddV <TVertex>(this IGraphTraversalSource graphTraversalSource, TVertex vertex, JsonSerializerSettings serializationSettings) where TVertex : VertexBase { var label = LabelNameResolver.GetLabelName(typeof(TVertex)); var traversal = graphTraversalSource.AddV(label); traversal = TraversalHelper.AddObjectProperties(traversal, vertex, serializationSettings); return(traversal.AsSchemaBound <object, TVertex>()); }
/// <summary> /// Gets the name of the label of the property's type. /// </summary> /// <param name="sourceType">Type of the source object from which the lambda started.</param> /// <param name="lambda">The lambda.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">lambda</exception> /// <exception cref="ArgumentException"></exception> private static string GetLabelName(Type sourceType, LambdaExpression lambda) { var propInfo = GetPropertyInfo(lambda); if (sourceType != propInfo.ReflectedType && !sourceType.IsSubclassOf(propInfo.ReflectedType)) { throw new ArgumentException($"Expression '{lambda}' refers to a property that is not from type {sourceType}."); } return(LabelNameResolver.GetLabelName(propInfo)); }