Created
November 11, 2011 18:26
-
-
Save kal/1358776 to your computer and use it in GitHub Desktop.
BrightstarDB SPARQL Endpoint Controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Web.Mvc; | |
using NetworkedPlanet.Brightstar.Client; | |
namespace NetworkedPlanet.BrightStar.Samples.NerdDinner.Controllers | |
{ | |
public class SparqlController : Controller | |
{ | |
[ValidateInput(false)] | |
public ActionResult Index(string query) | |
{ | |
if (String.IsNullOrEmpty(query)) | |
{ | |
return View("Error"); | |
} | |
var client = BrightstarService.GetClient(); | |
var results = client.ExecuteQuery("NerdDinner", query); | |
return new FileStreamResult(results, "application/xml; charset=utf-16"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BrightstarDB uses SPARQL as its primary query language. Because of this and because all the entities you create with the BrightstarDB entity framework are RDF resources, it is possible to turn your application into a part of the Linked Data web with just a few lines of code. The easiest way to achieve this is to add a controller for running SPARQL queries. This gist shows the outline of just such a controller that queries the BrightstarDB store named "NerdDinner"