2.12.3. Displaying RDF Data

One advantage of using Virtuoso as the data store is the seamless way in which we can use this use this application to display dereferencable IRIs and explore RDF linked data.

The Virtuoso SPASQL interface allows RDF data in the Virtuoso Quad store to be queried using SPARQL from any SQL interface by simply prefixing the SPARQL query with the keyword SPARQL. We will use the SPASQL interface to create a view containing the IRIs of the Employees in the the Demo RDF data in Virtuoso.

Step 1 - Create the View in Virtuoso

  1. Open the Virtuoso Conductor.

  2. In isql execute the following statement. Remember to use the appropriate hostname and port number of your Virtuoso installation, typically example.com for a default installation or whatever the URIQA DefaultHost Virtuoso configuration parameter was set to when the demo database VAD package was installed.

    CREATE VIEW Demo.demo.sparqlview as
    PREFIX nwind: <http://demo.openlinksw.com/schemas/northwind#>
    FROM <http://demo.openlinksw.com/Northwind>
        ?s a nwind:Employee

Step 2 - Modify the Solution To use the View

  1. Delete the existing Employee model and add a new one that comprises this new view.

    Figure 2.175. .NET RIA Services Application

    .NET RIA Services Application

  2. Delete the DomainService. Build the solution and add a new DomainService called EmployeeService. Select the sparqlview entity. Build the solution.

    Figure 2.176. .NET RIA Services Application

    .NET RIA Services Application

  3. Modify the code in mainpage.xaml.cs so it uses the sparqview entity. It should look like this:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using DemoApplication.Web;
    using System.Windows.Ria.Data;
    namespace DemoApplication
        public partial class MainPage : UserControl
            private EmployeeContext _employeeContext = new EmployeeContext();
            public MainPage()
                LoadOperation<sparqlview> LoadOp =
                this.EmployeeGrid.ItemsSource = LoadOp.Entities;
  4. Build and run the application. You will see a list of IRIs that identify the Northwind employees.

    Figure 2.177. .NET RIA Services Application

    .NET RIA Services Application

To realize the power of linked data we would now liked to begin exploring this data by clicking on these IRIs.

Step 3 - Make Hyperlinks From IRIs

  1. Modify the DataGrid in MainPage.xaml to bind the IRI in each cell of the grid to a Hyperlink button. We set the AutoGenerateColumns property of the DataGrid to False then add our own Template for the column. MainPage.xaml should look like this:

    <UserControl xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"  x:Class="DemoApplication.MainPage"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
      <Grid x:Name="LayoutRoot">
          <data:DataGrid Name="EmployeeGrid" AutoGenerateColumns="False">
                    <data:DataGridTemplateColumn Header="Employee">
                                <StackPanel x:Name="DisplayEmployeeData"
                                            Margin="5" >
                                    <HyperlinkButton Content ="{Binding s}"
                                                     NavigateUri="{Binding s}"
  2. If we build and run the project now each IRI in the list appears as a hyperlink.

    Figure 2.178. .NET RIA Services Application

    .NET RIA Services Application

  3. Clicking on each of the links takes you to a new document that contains further links to information about each Employee. The Demo dataset can be explored further by following the dereferenceable IRIs in the description pages.

    Figure 2.179. .NET RIA Services Application

    .NET RIA Services Application

    Figure 2.180. .NET RIA Services Application

    .NET RIA Services Application