public void TestCustomTriplesQuery() { string storeName = MakeStoreName("TestCustomTriplesQuiery", Configuration.PersistenceType); var people = new Person[10]; using (var dataObjectStore = _dataObjectContext.CreateStore(storeName)) { using (var context = new MyEntityContext(dataObjectStore)) { for (int i = 0; i < 10; i++) { var person = new Person { Age = 40 - i, Name = "Person #" + i }; context.Persons.Add(person); people[i] = person; } context.SaveChanges(); } } using (var dataObjectStore = _dataObjectContext.OpenStore(storeName)) { using (var context = new MyEntityContext(dataObjectStore)) { const string query = @" select ?s ?p ?o where { ?s ?p ?o. ?s a <http://www.example.org/schema/Person> } "; IList<Person> results = context.ExecuteQuery<Person>(query).ToList(); Assert.AreEqual(10, results.Count); foreach (Person person in results) { Assert.AreNotEqual(0, person.Age); } } } }
public void TestCustomTriplesQueryWithOrderedSubjects() { string storeName = Guid.NewGuid().ToString(); var people = new Person[10]; using (var dataObjectStore = _dataObjectContext.CreateStore(storeName)) { using (var context = new MyEntityContext(dataObjectStore)) { for (int i = 0; i < 10; i++) { var person = new Person { Age = 40 - i, Name = "Person #" + i }; context.Persons.Add(person); people[i] = person; } context.SaveChanges(); } } using (var dataObjectStore = _dataObjectContext.OpenStore(storeName)) { using (var context = new MyEntityContext(dataObjectStore)) { var query = @" select ?s ?p ?o where { ?s ?p ?o. ?s a <http://www.example.org/schema/Person> } order by ?s "; IList<Person> results; results = context.ExecuteQuery<Person>(new SparqlQueryContext(query) { ExpectTriplesWithOrderedSubjects = true }).ToList(); Assert.AreEqual(10, results.Count); foreach (Person person in results) { Assert.AreNotEqual(0, person.Age); } } } }