Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Query Projection

Efimster edited this page May 17, 2014 · 3 revisions

Query projection can be dynamic or static (typed).

Dynamic projection defines with "dynamic" type parameter:

ISPARQLQueryable<dynamic>  query = new SPARQLQuery<dynamic>(dyno);

Static projection defines with type parameter of predefined type:

public class Person
{
   public string Name { get; set; }
   public string MBox { get; set; }
   public int Rating { get; set; }
}
ISPARQLQueryable<Person> query = new SPARQLQuery<Person>(dyno);
Person person = query.Match(s: "?x", p: "foaf:name", o: o => o.Name)
 .Optional(s: "?x", p: "foaf:mbox", o: o => o.MBox)
 .Optional(s: "?x", p: "foaf:rating", o: o => o.Rating).And(p: "foaf:rating", o: 5).End()
 .Prefix("foaf:", "http://xmlns.com/foaf/0.1/")
 //Select() - select expression could be omitted
.AsEnumerable()
.First();

Clone this wiki locally