/// <summary> /// Simple example of how to create a new store, insert some simple data in the Ntriples (link) format, and then query /// using SPARQL. /// </summary> public static void UsingBasicClientToInsertAndQueryData() { var bc = new BasicClient(); // create a store var storeUri = bc.CreateStore(new Uri("http://*****:*****@" # data in Ntriple format. <http://www.networkedplanet.com/people/bob> <http://www.networkedplanet.com/types/worksfor> <http://www.networkedplanet.com/companies/networkedplanet> . <http://www.networkedplanet.com/people/jill> <http://www.networkedplanet.com/types/worksfor> <http://www.networkedplanet.com/companies/networkedplanet> . <http://www.networkedplanet.com/people/john> <http://www.networkedplanet.com/types/worksfor> <http://www.networkedplanet.com/companies/networkedplanet> . "; // create a simple transaction that adds triples to the store var txn = new Transaction {TriplesToAdd = dataToInsert}; // post the transaction and wait for it to complete. The alternative is to fire and forget, or pass in a call back. // todo: these other options arent available yet. var jobUri = bc.PostTransaction(storeUri, txn); // query for data const string query = "select ?person where { ?people <http://www.networkedplanet.com/types/worksfor> <http://www.networkedplanet.com/companies/networkedplanet> . }"; // execute sparql query and get SPARQL result XML. var result = bc.Query(storeUri, query); // Here we use a couple of XElement SPARQL result set specific extension methods, Rows and GetColumnValue //foreach (var resultRow in result.Rows) //{ // Console.WriteLine(resultRow.GetColumnValue("person")); //} }
/// <summary> /// Simple example of how to create a new store, insert some simple data in the Ntriples (link) format, and then query /// using SPARQL. /// </summary> public static void UsingBasicClientToInsertAndQueryData() { var bc = new BasicClient(); // create a store var storeUri = bc.CreateStore(new Uri("http://*****:*****@" # data in Ntriple format. <http://www.networkedplanet.com/people/bob> <http://www.networkedplanet.com/types/worksfor> <http://www.networkedplanet.com/companies/networkedplanet> . <http://www.networkedplanet.com/people/jill> <http://www.networkedplanet.com/types/worksfor> <http://www.networkedplanet.com/companies/networkedplanet> . <http://www.networkedplanet.com/people/john> <http://www.networkedplanet.com/types/worksfor> <http://www.networkedplanet.com/companies/networkedplanet> . "; // create a simple transaction that adds triples to the store var txn = new Transaction { TriplesToAdd = dataToInsert }; // post the transaction and wait for it to complete. The alternative is to fire and forget, or pass in a call back. // todo: these other options arent available yet. var jobUri = bc.PostTransaction(storeUri, txn); // query for data const string query = "select ?person where { ?people <http://www.networkedplanet.com/types/worksfor> <http://www.networkedplanet.com/companies/networkedplanet> . }"; // execute sparql query and get SPARQL result XML. var result = bc.Query(storeUri, query); // Here we use a couple of XElement SPARQL result set specific extension methods, Rows and GetColumnValue //foreach (var resultRow in result.Rows) //{ // Console.WriteLine(resultRow.GetColumnValue("person")); //} }