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(); }
public void Adding_attribute_mappings_for_an_Assembly_twice_should_add_only_one_repository_single_call() { // given var withMappings = typeof(IPerson).GetTypeInfo().Assembly; // when _entityContextFactory.WithMappings( m => { m.FromAssembly(withMappings); m.FromAssemblyOf <IPerson>(); }); // then _entityContextFactory.Mappings.Should().BeOfType <MappingsRepository>() .Which.Sources.Count(source => source.Description.Contains(withMappings.FullName)).Should().Be(2); }
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()); }