public void Persist1() { 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"); Console.WriteLine(store.UpdateProcessor.GetSaveCommandText(t, null)); store.UpdateProcessor.SaveObject(t, null); IQueryable<Track> qry = new RdfDataContext(store).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"); }
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); }
public void JosekiQueryWithProjection() { LinqTripleStore ts = new LinqTripleStore(@"http://localhost:2020/music"); IRdfQuery<Track> qry = new RdfDataContext(ts).ForType<Track>(); var q = from t in qry where t.Year == "2007" && t.GenreName == "Rory Blyth: The Smartest Man in the World" select new { t.Title, t.FileLocation }; foreach (var track in q) { Console.WriteLine(track.Title + ": " + track.FileLocation); } }
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 MusicDataContext(LinqTripleStore store) : base(store){}
/// <summary> /// Creates a new Data Context that uses the given LINQ Triple Store /// </summary> /// <param name="store">LINQ Triple Store</param> public RdfDataContext(LinqTripleStore store) { this.store = store; }
public void QueryTypeTest() { mocks = new MockRepository(); LinqQueryMethod queryType = LinqQueryMethod.RemoteSparql; LinqTripleStore ts = new LinqTripleStore("http://www.tempuri.com"); IRdfContext context = mocks.CreateMock<RdfDataContext>(ts); QueryFactory<Task> target = new QueryFactory<Task>(queryType, context); LinqQueryMethod val = LinqQueryMethod.RemoteSparql; Assert.AreEqual(val, target.QueryType, "VDS.RDF.Linq.QueryFactory<T>.QueryType was not set correctly."); // Assert.Fail("Generics testing must be manually provided."); }
public MyOntologyDataContext(LinqTripleStore store) : base(store) { }
protected LinqTripleStore CreateOnlineTripleStore() { LinqTripleStore ts = new LinqTripleStore(Properties.Settings.Default.testSparqlEndpoint); return ts; }