This project has moved. For the latest updates, please go here.

[MVC5][Entity Framework] How to expose an entity as a standard RDF/XML

Jul 8, 2016 at 1:19 PM
Hello,

I have a controller that have a method called 'RDF' like this:
public class CollegeController : Controller
{
     UniversityDataContext _dataContext = new UniversityDataContext();
     public ActionResult RDF(string id) {
          var college = _dataContext.Colleges.FirstOrDefault(c => c.Id.Equals(id));
          return college == null ? View("404") : View(college);
     }
}
I want to change the action method code so that it returns an RDF/XML as a result, something like this:
<rdf:rdf xmlns:geo="http://aims.fao.org/aos/geopolitical.owl#"
         xmlns:skos="http://www.w3.org/2004/02/skos/core#"
         xmlns:event="http://purl.org/NET/c4dm/event.owl#"
         xmlns:dcelem="http://purl.org/dc/elements/1.1/"
         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:bibo="http://purl.org/ontology/bibo/"
         xmlns:foaf="http://xmlns.com/foaf/0.1/"
         xmlns:owl="http://www.w3.org/2002/07/owl#"
         xmlns:dcterms="http://purl.org/dc/terms/"
         xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

    <rdf:description rdf:about="http://tishreen.edu.sy/College/5cac1673-fbb4-4aab-b491-9f610d3f378f">

    <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Agent" />
    <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Organization" />
    <rdf:type rdf:resource="http://tishreen.edu.sy/ontology#College" />

    <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Mechanical And Electrical Engineering</rdfs:label>

    <rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string"></rdfs:comment>

    <org:subOrganizationOf rdf:resource="http://tishreen.edu.sy/University/6ad0544c-5f8c-4934-9aeb-00f1b4fe115e" />

</rdf:description>
How to do that in BrightstarDB Entity Framework.

Thanks :)