Пример #1
0
        public void ORDERBYAscClause()
        {
            var expectedClause = "ORDER BY ASC(?uri)";
            var orderByClause  = new dotNetSPARQL.Query.OrderByClause("uri", false);

            Assert.AreEqual(expectedClause, orderByClause.ToString());
        }
Пример #2
0
        public void SELECTUnionOrderByClauses()
        {
            var expectedQuery = "SELECT ?uri, ?label WHERE {{ ?uri <http://www.w3.org/2000/01/rdf-schema#label> ?label } {<http://dbpedia.org/resource/Paris> <http://www.w3.org/2000/01/rdf-schema#label> ?label} UNION {<http://dbpedia.org/resource/Montreal> <http://www.w3.org/2000/01/rdf-schema#label> ?label}} ORDER BY ASC(?label)";
            var subject       = new UriNode("http://dbpedia.org/resource/Paris");
            var predicate     = new UriNode("http://www.w3.org/2000/01/rdf-schema#label");
            var obj           = new VariableNode("label");
            var triple        = new Triple(subject, predicate, obj);
            var triples       = new List <Triple> {
                triple
            };

            subject = new UriNode("http://dbpedia.org/resource/Montreal");
            triple  = new Triple(subject, predicate, obj);
            triples.Add(triple);
            var unionClause = new dotNetSPARQL.Query.UnionClause(triples);

            triple = new Triple(
                new VariableNode("uri"),
                new UriNode("http://www.w3.org/2000/01/rdf-schema#label"),
                new VariableNode("label"));
            var orderByClause = new dotNetSPARQL.Query.OrderByClause("label");
            var select        = new dotNetSPARQL.Query.Select(new List <Triple>()
            {
                triple
            }, new dotNetSPARQL.Query.BaseClause[] { orderByClause, unionClause }, new string[] { "uri", "label" });

            Assert.AreEqual(expectedQuery, select.ToString());
        }
Пример #3
0
        public void ORDERBYQuery()
        {
            var expectedQuery = "SELECT WHERE { <http://dbpedia.org/resource/Paris> <http://dbpedia.org/ontology/wikiPageExternalLink> ?uri } ORDER BY DESC(?uri)";

            var subject       = new UriNode("http://dbpedia.org/resource/Paris");
            var predicate     = new UriNode("http://dbpedia.org/ontology/wikiPageExternalLink");
            var obj           = new VariableNode("uri");
            var triple        = new Triple(subject, predicate, obj);
            var orderByClause = new dotNetSPARQL.Query.OrderByClause("uri", true);

            var clauses = new dotNetSPARQL.Query.BaseClause[] { orderByClause };
            var triples = new List <Triple> {
                triple
            };
            var selectCountQuery = new dotNetSPARQL.Query.Select(
                triples, clauses, new string[0]);

            Assert.AreEqual(expectedQuery, selectCountQuery.ToString());
        }