RDF - Object Mapping for RDF in .net

MakoLab open-source component

Entities’ RDF types

Asserting rdf:type

Entities in the previous examples were not mapped to any RDF classes. If an entity type is mapped with an RDF type, that type is asserted whenever the IEntityContext#AsEntity(), IEntityContext#Load() and IEntityContext#Create() methods are called.

This means that given an updated mapping for IPerson and IEmployee, whenever it’s created an rdf:type triple is asserted.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
using RomanticWeb;

IEntityContext context = // ...
Uri personUri = new Uri("http://example.org/ThePerson");

var person = context.Create<IPerson>(personUri);
person.Name = "John";
person.LastName = "Doe";

var employee = person.AsEntity<IEmployee>();
employee.Salary = 2000;
employee.EmployerName = "cool soft inc";

context.Commit();
1
2
3
4
5
[Class("foaf", "Person")]
public interface IPerson : IEntity
{
    /* ... */
}
1
2
3
4
5
[Class("ex", "Employee")]
public interface IEmployee : IEntity
{
    /* ... */
}
1
2
3
4
5
6
<http://example.org/ThePerson>
    foaf:givenName "John"^^xsd:string ;
    foaf:familyName "Doe"^^xsd:string ;
    ex:salary 2000 ;
    ex:employer "cool soft inc"^^xsd:string ;
    rdf:type foaf:Person, ex:Employee .