예제 #1
0
		private static void TestConnectionCreationForTripleStore(LinqTripleStore ts1)
		{
			IRdfContext context = new RdfDataContext(ts1);
			QueryFactory<Track> factory = new QueryFactory<Track>(ts1.QueryMethod, context);
			IRdfQuery<Track> qry1 = context.ForType<Track>();
			IRdfConnection<Track> rdfConnection = factory.CreateConnection(qry1);
			Assert.IsNotNull(rdfConnection);
		}
예제 #2
0
        public void PersistToGraph1()
        {
            LinqTripleStore store = new LinqTripleStore(CreateMemoryStore());

            Track t = new Track()
            {
                AlbumName = "Test Album",
                ArtistName = "Some Artist",
                Comment = "blah de blah",
                GenreName = "Easy Listening",
                InstanceUri = "http://example.org/music/someAlbum/tracks/1",
                Title = "Track 1",
                Rating = 5,
                Year = "2010"
            };

            Assert.IsTrue(store.SupportsPersistence, "Persistence should be supported by in-memory stores");

            String text = store.UpdateProcessor.GetSaveCommandText(t, "http://example.org/someGraph");
            Console.WriteLine(text);
            Assert.IsTrue(text.Contains("GRAPH <"), "Persistence Command should have contained a GRAPH clause");

            store.UpdateProcessor.SaveObject(t, "http://example.org/someGraph");

            RdfDataContext context = new RdfDataContext(store);
            IQueryable<Track> qry = context.ForType<Track>();
            IQueryable<Track> q = from x in qry
                                  where x.ArtistName == "Some Artist"
                                  select x;

            Assert.IsTrue(q.Count() > 0, "Expected 1 or more results");
            Assert.IsTrue(q.Count() == 1, "Expected only 1 result");

            //Try setting Graph to non-existent Graph - should then throw an error
            try
            {
                context.DefaultGraph = "http://example.org/noSuchGraph";
                int count = q.Count();
                Assert.Fail("Should have thrown an error as tried to query a non-existent Graph");
            }
            catch
            {
                Console.WriteLine("Errored as expected when a non-existent Graph was used");
            }

            //Try setting Graph to correct Graph, should then get the 1 result as expected
            context.DefaultGraph = "http://example.org/someGraph";
            Assert.IsTrue(q.Count() == 1, "Expected only 1 result");
        }
 public void TestGetAllTasks()
 {
     RdfDataContext ctx = new RdfDataContext(CreateSparqlTripleStore());
     var q = (from t in ctx.ForType<Task>()
             select t).ToArray().Distinct();
     Assert.IsTrue(q.Count() == 12);
 }
예제 #4
0
 public void Query5()
 {
     TripleStore ts = CreateOnlineTripleStore();
     var ctx = new RdfDataContext(ts);
     IRdfQuery<Track> qry = ctx.ForType<Track>();
     IQueryable<Track> q = from t in qry
                           where t.GenreName == "Rory Blyth: The Smartest Man in the World"
                           select t;
     foreach (Track track in q)
     {
         track.Rating = 5;
     }
     ctx.SubmitChanges();
 }