SPARQL Query using dotnotrdf API

by

You may be wondering what is Sparql?

What for? 

In this article will try to answer this question, and talk a bit about SPARQL.

According to W3C SPARQL is an RDF query language, that is, a semantic query language for databases, able to retrieve and manipulate data stored in Resource Description Framework (RDF) format.

it is instructions to query RDF, it is similar to SQL query.

Example:

 

I do not want to talk more IT jargon, let's make it easy.

many of us using Alex, google or Cortana this AI devises or software.

How they are understanding what is written in your HTML page.

How they will recognize this text is talking about Person, not about Place or Pace of hardware.

For example, if you google Hilton word, how google understand that is Person, not Hotel!

Rdf came to solve the problem, By giving a description to the text to make it has meaning.

How?

By Using RDFa or Microdata and write our own ontology to describe things.

Example for RDFa with HTML:

 

In the Last HTML page, you may notice the new code in the red color.

This code describes the HTML page, telling Alex this is an Article, title and the body of the article.

So when you Ask Alex: Who is the creator of the Article?

Alex: will give the correct answer (Alice).

the subject is not that complicated, I just give you small or brief words to describe it to you.

and our main article was about SPARQL Query language.

I have developed web solution, through the website you can upload you owl file and query it.

demo: http://sparql.a-hamoud.com/Home/Index

 I have used dontnetrdf API and ASP.NET MVC 5 with SQL Server to store the owl files and manage the users.

 

 

 

 

ASP.NET MVC Fancygrid part2

by

Hi,

again with 2 tutorial ASP.NET MVC FancyGird.

After we create our data in Part 1,

Now will create new Controller Call it

StudentController.

The most important one is, what I highlight it (Yellow).

First one is declared our Interface,

  private readonly IStudent repositoryStudent;

building contractor.

 public StudentController(IStudent repoStudent)
        {
            repositoryStudent = repoStudent;
        }

 

This one our main job :)

 public JsonResult StudentJSON() {
            //    Student model = new Student();
           List<Student> model = new List <Student>();
            model = repositoryStudent.GetStudent;
            return Json(model, JsonRequestBehavior.AllowGet);
        }
 

From StudentJSON method will send Data to Our FancyGrid using AJAX.

Next step, Add View Just right click on DataTablesJQuery() and add Empty View.

So, if you visit FancyGrid website and check how to use it from the documentation page.

Previews Photo Show you what you need to add, its just 2 lines.

//FancyGrid
<link href="http://code.fancygrid.com/fancy.min.css" rel="stylesheet">
<script src="http://code.fancygrid.com/fancy.min.js"></script>

Past them in your page.

same next photo

Full View Page Code:


<link href="http://code.fancygrid.com/fancy.min.css" rel="stylesheet">
<style>
    .image-staff img {
        margin-top: -15px;
        border-radius: 2px;
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }
</style>
<h2>DataTables JQuery</h2>

 <div id="container"></div>

 @section Scripts{
<script src="http://code.fancygrid.com/fancy.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {       
        $.ajax({
            type:"GET",
            url: "StudentJSON",
            dataType: "json",
            success: function (result) {                              
                new FancyGrid({
                    title: 'Student',
                    renderTo: 'container',
                    width: 750,
                    height: 450,
                    data: result,
                    defaults: {
                        editable: true,
                        resizable: true,
                        sortable: true,
                        filter: {
                            header: true,
                            emptyText: 'Search'
                        }
                    },
                    paging: true,

                    columns: [{
                        index: 'ID',
                        title: 'ID',
                        type: 'string'
                    }, {
                            type: 'string',
                            index: 'FirstName',
                            title: 'FirstName'
                        }
                        , {
                        type: 'string',
                        index: 'LastName',
                        title: 'LastName'
                    }, {
                            type: 'string',
                            index: 'City',
                            title: 'City'}, {
                            type: 'image',
                            index: 'image',
                            title: 'Photo',
                            cls: 'image-staff',
                            width: 100,
                            flex: 1 }]
                });
            },
            error: function () {
                alert("Error loading data! Please try again.");
            }
        });
    });
</script>
    }

 

OK, don't be scare, you will say it's not too many lines.

After you see the result.

So, let's talk about the HTML code first,

We added the javascript file and style file.

After that we create new

<div id="container"></div>

AJAX code responsible to execute StudentJSON() method and get the result to send it to FancyGrid.

 new FancyGrid({
    renderTo: 'container',
    width: 500,
    height: 400,
    data: result,
    columns: [{}]

}

Just you need on more thing,

Columns,you need yo write column Name ,Index and which data type.

in our example was number,image and string.

last column was image datatype becouse we sent image.

columns: [{
                        index: 'ID',
                        title: 'ID',
                        type: 'string'
                    }, {
                            type: 'string',
                            index: 'FirstName',
                            title: 'FirstName'
                        }
                        , {
                        type: 'string',
                        index: 'LastName',
                        title: 'LastName'
                    }, {
                            type: 'string',
                            index: 'City',
                            title: 'City'}, 
                                  
                           {type: 'image',
                            index: 'image',
                            title: 'Photo',
                            cls: 'image-staff',
                            width: 100}]

 

The result after running your project,

 

there are too many features in this tool, I just highlight in yellow paging, filtering, sorting and add image ;) 

if you back to the code you can see paging: true, this 2 words to enable paging.

to enable sorting, filtering, resizable and editable to all columns just add this piece of code.

defaults: {
                        editable: true,
                        resizable: true,
                        sortable: true,
                        filter: {
                            header: true,
                            emptyText: 'Search'
                        }
                    },

 

For more information and more and more features, you can visit https://www.fancygrid.com website 

or if you like to watch it on Youtube, How to use FancyGrid with ASP.NET MVC and SQL Server

just visit my Channel

ASP.NET MVC Fancygrid part1

by

Hi,

In this article will write about Grid, there are too many Grid tools you can find.

but what exactly we want from Grid to display, features and how to code it or work with it from coding side.

Sure everybody tries to find the useful tool and easy with coding.

So, I found one easy to work with from coding side and too many features, help your page to be good and easy.

FancyGrid, I found it on Twitter.

 

When I checked the website, I was shocked.

Why ? I will not tell you that 

let's try together to dig up in it, with ASp.NET MVC Application.

First Step, Create new ASP.NET MVC Application.

Follow the Photos.

 

Choose MVC,

 

So, Now we need data to send it to our HTML page and display it on FancyGrid.

First, we need to create new Class in Models folder and call it Student.

 

Next Step, Create Folder Call it Services will put inside it,

a new class (IStudent class).

 

 

After Create our Interface, we need to create Repository Folder with StudentRepository class.

In StudentRepository Class, I have fake data just to show you how it will be in our HTML page.

sure you can Use data from your SQL Server database, using Entry Framework.

part2

Paging in ASP.NET MVC part 2

by

Hi, again this is Part 2 from Paging in ASP.NET MVC.

In Part 1, I showed you how to add all data required.

Now let's try to finish what we start together.

Now will try to add new Controller and Call it StudentController.

The most important one is, what I highlight it (Yellow).

First one is declared our Interface,

  private readonly IStudent repositoryStudent;

building contractor.

 public StudentController(IStudent repoStudent)
        {
            repositoryStudent = repoStudent;
        }

 

This one our main job :)

ActionResult Index,

First int? page=1, this for your request, when it will be null, the default page will be first one page=1.

next step is reading data from our Repository.

  var model = repositoryStudent.GetStudent;

if no page was specified in the query string, default to the first page (1)

  var pageNumber = page ?? 1; 

 will only contain 25 products max because of the pageSize

  var onePageOfProducts = products.ToPagedList(pageNumber, 25); 
  

Don't forget to call X.PagedList .

using X.PagedList;

Now to our HTML code.

Just generate Index view.

next Photo will show you what you will have new change.

Again same what we call in our controller, we should call 2 library from X.PagedList.

@using X.PagedList.Mvc;  
@using X.PagedList;

after that to have a good style you need to add,

<link href="/Content/PagedList.css" rel="stylesheet" type="text/css" />

so after all that the most important part is.

@Html.PagedListPager((IPagedList)Model, page => Url.Action("Index", new { page }))

 

The result will be same next photo.

 

 

 

Youtube Video.....

 

Hope this article is helpful.

If you have any question, just write in the comment.

 

Paging in ASP.NET MVC part 1

by

Hi,

Today I'm going to write about Paging in ASP.NET MVC.

First, if someone asks you about paging, why?

Sometimes, we have too many rows, Photos, articles and Products you don't want to display all of them in same time,

or let's say, you don't want load 100K row in one click, this will be a big issue with your application.

  So, the solution will be is paging.

and don't forget to use IQueryable rather than List or IEnumerable.

Now, To work our first step is to create new ASP.NET MVC Project.

Follow the Photos.

 

Choose MVC,

 

Next Step, Add X.PagedList  From NuGet packages.

So, Now we need data to send it to our HTML page and display it in the table.

First, we need to create new Class in Models folder and call it Student.

 

Next Step, Create Folder Call it Services will put inside it,

a new class (IStudent class).

 

 

After Create our Interface, we need to create Repository Folder with StudentRepository class.

In StudentRepository Class, I have fake data just to show you how it will be in our HTML page.

sure you can Use data from your SQL Server database, using Entry Framework.

 

Part2