/// <summary>
        /// Executes SPARQL Update query
        /// </summary>
        /// <typeparam name="T">element type</typeparam>
        /// <param name="source">query</param>
        /// <returns>result object</returns>
        public static object ExecuteUpdate <T>(this ISPARQLQueryable <T> source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            return(source.Provider.ExecuteUpdate(source.Expression));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Converts to IEnumerable. Bridge to LINQ to Object
        /// </summary>
        /// <typeparam name="T">element type</typeparam>
        /// <param name="source">query</param>
        /// <returns>enumeration</returns>
        public static IEnumerable <T> AsEnumerable <T>(this ISPARQLQueryable <T> source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            return((IEnumerable <T>)source.Provider.ExecuteEnumerable <T>(source.Expression));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Match expression
        /// </summary>
        /// <typeparam name="T">element type</typeparam>
        /// <param name="source">query</param>
        /// <param name="o">object</param>
        /// <returns>query</returns>
        private static ISPARQLQueryable <T> And_1 <T>(this ISPARQLQueryable <T> source, dynamic o)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            return(source.Provider.CreateSPARQLQuery <T>(Expression.Call(null, ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(new Type[] { typeof(T) }),
                                                                         new Expression[] { source.Expression, Expression.Constant(o) })));
        }
        /// <summary>
        /// Exists expression
        /// </summary>
        /// <typeparam name="T">element type</typeparam>
        /// <param name="source">query</param>
        /// <param name="s">subject</param>
        /// <param name="p">predicate</param>
        /// <param name="o">object</param>
        /// <returns>query</returns>
        public static ISPARQLMatchQueryable <T> Exists <T>(this ISPARQLQueryable <T> source, string s, string p, dynamic o)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            return((ISPARQLMatchQueryable <T>)source.Provider.CreateSPARQLQuery <T>(Expression.Call(null, ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(new Type[] { typeof(T) }),
                                                                                                    new Expression[] { source.Expression, Expression.Constant(s, typeof(string)), Expression.Constant(p), Expression.Constant(o) })));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Prefix expression
        /// </summary>
        /// <typeparam name="T">element type</typeparam>
        /// <param name="source">query</param>
        /// <param name="prefix">prefix</param>
        /// <param name="iri">iri</param>
        /// <returns>query</returns>
        public static ISPARQLQueryable <T> Prefix <T>(this ISPARQLQueryable <T> source, string prefix, string iri)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            return(source.Provider.CreateSPARQLQuery <T>(Expression.Call(null, ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(new Type[] { typeof(T) }),
                                                                         new Expression[] { source.Expression, Expression.Constant(prefix), Expression.Constant(iri) })));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Group expression
        /// </summary>
        /// <typeparam name="T">element type</typeparam>
        /// <param name="source">query</param>
        /// <returns>query</returns>
        public static ISPARQLMatchQueryable <T> Group <T>(this ISPARQLQueryable <T> source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            return((ISPARQLMatchQueryable <T>)source.Provider.CreateSPARQLQuery <T>(Expression.Call(null, ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(new Type[] { typeof(T) }),
                                                                                                    new Expression[] { source.Expression })));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Select expression
        /// </summary>
        /// <typeparam name="T">element type</typeparam>
        /// <param name="source">query</param>
        /// <param name="items"></param>
        /// <returns>query</returns>
        public static ISPARQLQueryable <T> Select <T>(this ISPARQLQueryable <T> source, params string[] items)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }


            return(source.Provider.CreateSPARQLQuery <T>(Expression.Call(null, ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(new Type[] { typeof(T) }),
                                                                         new Expression[] { source.Expression, Expression.Constant(items, typeof(string[])) })));
        }
        /// <summary>
        /// Minus expression
        /// </summary>
        /// <typeparam name="T">element type</typeparam>
        /// <param name="source">query</param>
        /// <param name="triple">triple</param>
        /// <returns>query</returns>
        public static ISPARQLMatchQueryable <T> Minus <T>(this ISPARQLQueryable <T> source, string triple)
        {
            var nodes = triple.SplitExt(" ").ToArray();

            return(source.Minus(s: nodes[0], p: nodes[1], o: nodes[2]));
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Select expression. Projection
 /// </summary>
 /// <typeparam name="T">element type</typeparam>
 /// <param name="source">query</param>
 /// <returns>query</returns>
 public static ISPARQLQueryable <T> Select <T>(this ISPARQLQueryable <T> source)
 {
     return(source.Select(typeof(T)));
 }
Ejemplo n.º 10
0
 public ISPARQLQueryable <T> Merge(ISPARQLQueryable <T> otherQuery)
 {
     return(provider.Merge <T>(this, otherQuery));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Match expression
 /// </summary>
 /// <typeparam name="T">element type</typeparam>
 /// <param name="source">query</param>
 /// <param name="s"></param>
 /// <param name="p"></param>
 /// <param name="o"></param>
 /// <returns>query</returns>
 public static ISPARQLMatchQueryable <T> Match <T>(this ISPARQLQueryable <T> source, Expression <Func <T, dynamic> > s, string p, Expression <Func <T, dynamic> > o)
 {
     return(source.Match <T>(s.GetMemberAccessName(), p, o.GetMemberAccessName()));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Match expression
 /// </summary>
 /// <typeparam name="T">element type</typeparam>
 /// <param name="source">query</param>
 /// <param name="s">subject</param>
 /// <param name="p">predicate</param>
 /// <param name="o">object</param>
 /// <returns>query</returns>
 public static ISPARQLMatchQueryable <T> Match <T>(this ISPARQLQueryable <T> source, Expression <Func <T, dynamic> > s, Expression <Func <T, dynamic> > p, dynamic o)
 {
     return(Match <T>(source, s.GetMemberAccessName(), p.GetMemberAccessName(), o));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Optional expression
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="source">query</param>
 /// <param name="s">subject</param>
 /// <param name="p">predicate</param>
 /// <param name="o">object</param>
 /// <returns>query</returns>
 public static ISPARQLMatchQueryable <T> Optional <T>(this ISPARQLQueryable <T> source, string s, Expression <Func <T, dynamic> > p, dynamic o)
 {
     return(Optional <T>(source, s, p.GetMemberAccessName(), o));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Optional expression
 /// </summary>
 /// <typeparam name="T">element type</typeparam>
 /// <param name="source">query</param>
 /// <param name="s">subject</param>
 /// <param name="p">predicate</param>
 /// <param name="o">object</param>
 /// <returns>query</returns>
 public static ISPARQLMatchQueryable <T> Optional <T>(this ISPARQLQueryable <T> source, Expression <Func <T, dynamic> > s, Expression <Func <T, dynamic> > p, Expression <Func <T, dynamic> > o)
 {
     return(source.Optional <T>(s.GetMemberAccessName(), p.GetMemberAccessName(), o.GetMemberAccessName()));
 }
        //public ISPARQLQueryable Merge(Expression expression, ISPARQLQueryable otherQuery)
        //{
        //    var translator1 = this.Translate(otherQuery.Expression);
        //    var translator2 = this.Translate(otherQuery.Expression);

        //    var prefixes = translator1.Prefixes.Union(translator2.Prefixes);
        //    var deleteClause = MergeGroups(translator1.DeleteClause, translator2.DeleteClause);

        //    return null;
        //}

        //private Group MergeGroups(Group group1, Group group2)
        //{
        //    return SPARQL.Group(group1.Items.Union(group2.Items).ToArray());
        //}

        public ISPARQLQueryable <T> Merge <T>(ISPARQLQueryable <T> baseQuery, ISPARQLQueryable <T> otherQuery)
        {
            var translator = new SPARQLMergeTranslator();

            return((ISPARQLMatchQueryable <T>)CreateSPARQLQuery <T>(translator.Merge(baseQuery.Expression, otherQuery.Expression)));
        }