public static void InitContext() { var contextFactory = new EntityContextFactory(); contextFactory.WithMappings((MappingBuilder builder) => { builder.FromAssemblyOf <INode>(); }); store = new TripleStore(); contextFactory.WithDotNetRDF(store); contextFactory.WithMetaGraphUri(new Uri(clientURI)); context = contextFactory.CreateContext(); }
static void Main() { ITripleStore store = new TripleStore(); store.LoadFromFile("input.trig"); var factory = new EntityContextFactory(); // it is also possible to add fluent/attribute mappings separately factory.WithMappings(mb => mb.FromAssemblyOf <IPerson>()); // this is necessary to tell where entities' data is stored in named graphs // see the input.trig file to find out how it does that factory.WithMetaGraphUri(new Uri("http://romanticweb.net/samples")); // this API bound to change in the future so that custom // namespaces can be added easily factory.WithOntology(new DefaultOntologiesProvider(BuiltInOntologies.DCTerms | BuiltInOntologies.FOAF)); factory.WithDotNetRDF(store); var context = factory.CreateContext(); foreach (var person in context.AsQueryable <IPerson>().Where(p => p.Name != "Karol")) { var pubId = "http://romanticweb.net/samples/publication/" + Guid.NewGuid(); var pub = context.Create <IPublication>(pubId); pub.Title = string.Format("Publication about RDF by {0} {1}", person.Name, person.LastName); pub.DatePublished = DateTime.Now; person.Publications.Add(pub); } context.Commit(); store.SaveToFile("output.trig", new TriGWriter()); }