Example #1
0
        // Helper method to compute expression joins
        private JoinedMapResult CreateJoinedMap(Resource property, GraphExpression expression)
        {
            var joinSegment             = new LabelledTreeNode <object, Term>(Root).AddChild(property, expression.Root);
            var joineMapComparisonSites = new List <JoinAddressPair> {
                new JoinAddressPair {
                    TreeAddress1 = new List <Term> {
                        property
                    }, TreeAddress2 = new List <Term>()
                }
            };
            IMap joinedMap = new JoinMap(new BgpMap(joinSegment), expression.Map, joineMapComparisonSites);

            var comparisonSites = new List <JoinAddressPair> {
                JoinAddressPair.RootComparison
            };

            return(new JoinedMapResult {
                Map = joinedMap, AddressPairList = comparisonSites
            });
        }
Example #2
0
        /// <summary>
        /// Left Join
        /// </summary>
        /// <param name="property"></param>
        /// <param name="expression"></param>
        /// <returns></returns>
        public GraphExpression LeftJoin(Resource property, GraphExpression expression)
        {
            var result = CreateJoinedMap(property, expression);

            return(new GraphExpression(new LeftJoinMap(Map, result.Map, result.AddressPairList)));
        }
Example #3
0
 /// <summary>
 /// Execute the query codified in the graph expression on the source
 /// </summary>
 /// <returns>A collection of graph results that match the graph expression</returns>
 public IEnumerable <LabelledTreeNode <object, Term> > Execute(GraphExpression graphExpression, IGraphSource source = null)
 {
     return(graphExpression.Map.Evaluate <T>(source ?? DefaultSource));
 }
Example #4
0
 /// <summary>
 /// Union
 /// </summary>
 /// <param name="graphExpression"></param>
 /// <returns></returns>
 public GraphExpression Union(GraphExpression graphExpression)
 {
     return(new GraphExpression(new UnionMap(Map, graphExpression.Map)));
 }
Example #5
0
 /// <summary>
 /// Expands the graph expression with the specified property and query.
 /// The new graph expression will bind a given context if and only if both the old expression and the addition bind
 /// </summary>
 /// <param name="property">property along which to expand</param>
 /// <param name="query">queryable graph required at the end of the property</param>
 /// <returns>a queryable graph</returns>
 public IQueryableGraph Require(Resource property, IQueryableGraph query)
 {
     return(new QueryableGraph(GraphProvider, GraphExpression.Join(property, query.GraphExpression)));
 }
Example #6
0
 /// <summary>
 /// Expands the graph expression with the specified property and terminal object, the return the terminal object
 /// The new graph expression will bind a given context if and only if both the old expression and the addition bind
 /// </summary>
 /// <param name="property">property along which to expand</param>
 /// <param name="object">object required at the end of the property, can be left null to insert a variable</param>
 /// <returns>a queryable graph</returns>
 public IQueryableGraph Select(Resource property, Term @object = null)
 {
     return(new QueryableGraph(GraphProvider, GraphExpression.Select(property, @object)));
 }
Example #7
0
 /// <summary>
 /// Expands the graph expression with the specified property and object.
 /// The new graph expression will bind a given context if and only if both the old expression and the addition bind
 /// </summary>
 /// <param name="property">property along which to expand</param>
 /// <param name="object">object required at the end of the property, can be left null to insert a variable</param>
 /// <returns>a queryable graph</returns>
 public IQueryableGraph Require(Resource property, Term @object = null)
 {
     return(new QueryableGraph(GraphProvider, GraphExpression.Join(property, @object)));
 }
Example #8
0
 /// <summary>
 /// Returns an instance of a QueryableGraph
 /// </summary>
 /// <param name="graphExpression">codifies the query to be executed</param>
 /// <param name="graphProvider">manages the translation of graph expression to generic graph query result</param>
 public QueryableGraph(IGraphProvider graphProvider, GraphExpression graphExpression = null)
 {
     GraphProvider   = graphProvider;
     GraphExpression = graphExpression ?? GraphExpression.Empty;
 }
Example #9
0
 /// <summary>
 /// Returns the first count bindings
 /// </summary>
 /// <param name="count">maximum number of elements to return</param>
 /// <returns>a queryable graph</returns>
 public IQueryableGraph Limit(int count)
 {
     return(new QueryableGraph(GraphProvider, GraphExpression.Slice(null, count)));
 }
Example #10
0
 /// <summary>
 /// Returns the union of two queries, the graph expressions are left unaltered.
 /// </summary>
 /// <param name="query"></param>
 /// <returns>a queryable graph</returns>
 public IQueryableGraph Union(IQueryableGraph query)
 {
     return(new QueryableGraph(GraphProvider, GraphExpression.Union(query.GraphExpression)));
 }
Example #11
0
 /// <summary>
 /// Expands the graph expression with the specified property and terminal query, then return the terminal query
 /// The new graph expression will bind a given context if and only if both the old expression and the addition bind
 /// </summary>
 /// <param name="property">property along which to expand</param>
 /// <param name="query">queryable graph required at the end of the property</param>
 /// <returns>a queryable graph</returns>
 public IQueryableGraph Select(Resource property, IQueryableGraph query)
 {
     return(new QueryableGraph(GraphProvider, GraphExpression.Select(property, query.GraphExpression)));
 }