Database Reference
In-Depth Information
the sample graph database used for these examples is loaded with data so that you can immediately begin
working with representative data in each of the graph models. In the case of the social graph—and for other graph
models, as well—you will login with the user ajordan . Going forward, please login with ajordan to see each of the
working examples.
Note
User Node Entity
I approach the social graph model by reviewing the code for creating a User node in the graph via the sign-up process.
Later in this section, you will briefly review the code to validate a user attempting to login. In each case, the code
contains brief validation routines to demonstrate the basics of running checks against data. In the case of sign-up, the
code will check to see if a User already exists with the same username.
Node Entities
To begin, open the User class located in the Models package. Like the other classes in the application, the User entity
has properties that are commonly found in similar applications, such as firstname and lastname (Listing 7-14).
One significant difference is that the NodeReference class is included. The NodeReference is added to the object
when called from the database and is especially helpful when doing Cypher queries that require the START clause to
complete the function or operation.
Listing 7-14. The User Object
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Neo4jClient;
namespace PracticalNeo4j_DotNet.Models
{
public class User
{
public long nodeId { get; set; }
public NodeReference noderef { get; set; }
public string userId { get; set; }
public string username { get; set; }
public string firstname { get; set; }
public string lastname { get; set; }
}}
Sign-Up
The HTML required for the user sign-up form is shown in Listing 7-15 and can be found in the {PROJECTROOT}/Views/
Home/index.cshtml file. The important item to note in the HTML form is that the graphStory object and then class
name and then property are used to specify what is passed to the controller and, subsequently, to the service layer for
saving to the database.
 
 
Search WWH ::




Custom Search