File: sqlite.cs

package info (click to toggle)
semweb 1.05%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 3,988 kB
  • ctags: 2,832
  • sloc: cs: 14,483; makefile: 180; sh: 107; perl: 20; ansic: 7
file content (28 lines) | stat: -rw-r--r-- 885 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using SemWeb;

public class Sqlite {
	const string RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
	const string FOAF = "http://xmlns.com/foaf/0.1/";
	
	static readonly Entity rdftype = RDF+"type";
	static readonly Entity foafPerson = FOAF+"Person";
	static readonly Entity foafname = FOAF+"name";

	public static void Main() {
		Store store = Store.Create("sqlite:rdf:Uri=file:foaf.sqlite;version=3");
		
		Entity newPerson = new Entity("http://www.example.org/me");
		store.Add(new Statement(newPerson, rdftype, foafPerson));
		store.Add(new Statement(newPerson, foafname, (Literal)"New Guy"));
		
		Console.WriteLine("These are the people in the file:");
		foreach (Entity s in store.SelectSubjects(rdftype, foafPerson)) {
			foreach (Resource r in store.SelectObjects(s, foafname))
				Console.WriteLine(r);
		}
		Console.WriteLine();
		
		store.Dispose();
	}
}