public void AddListAndKeepingReferenceToStart() { var rdf = new RdfData(new NodeFactory()); var g = rdf.GetGraph(rdf.Uri("graph:/g1")) .Update .Let(out var graphId); //(http://www.snee.com/bobdc.blog/2014/04/rdf-lists-and-sparql.html) // x:sub rdfs:first "one" // x.sub rdfs:rest _:1 // _:1 rdfs:first "two" // _:1 rdfs:rest _:2 // _:2 rdfs:first "three" // _:2 rdfs:rest rsf:nil g.For(rdf.Uri("x:sub")) .Let(out var listStart) .List(rdf.New("one"), rdf.New("two"), rdf.New("three")) .With(rdf.Uri("x:p")).Add(rdf.New("Extra data on last item")) //And jump back to starting subject. .ThenFor(listStart); var listModel = new RdfsList(rdf, rdf.GetGraph(graphId)); var items = listModel.GetList(listStart) .ToList(); Assert.AreEqual(3, items.Count, "Got 3 items from list"); Assert.AreEqual("two", items[1].Value <string>(), "2nd is as expected"); }
private void GetMyFavorites() { var rdf = RdfDataFactory.CreateNoLock(); var g = rdf.GetFullGraph(_myProfile); new NTripleFile(_data) .Read(g) .Wait(); //the list of favs. var favsList = g.Query .For(g.Id) .With(g.Uri("app:favorites")) .GetBlanks() .First(); //get list items. var myFavorites = new RdfsList(rdf, g) .GetList(favsList).ToArray(); Assert.IsTrue(myFavorites.Length > 0, "Got some favorites"); }