Skip to content

Instantly share code, notes, and snippets.

@kal
Created November 11, 2011 18:26
Show Gist options
  • Save kal/1358776 to your computer and use it in GitHub Desktop.
Save kal/1358776 to your computer and use it in GitHub Desktop.
BrightstarDB SPARQL Endpoint Controller
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");
}
}
}
@kal
Copy link
Author

kal commented Nov 11, 2011

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment