Coder Social home page Coder Social logo

neo4jrestnet's Introduction

Neo4jRestNet

.Net wrapper for the Neo4j REST server

Configuration:

<configuration>
    <connectionStrings>
        <add name="neo4j"  connectionString="http://localhost:7474/db/data/" />
        <add name="neo4jGremlinExtension"  connectionString="/ext/GremlinPlugin/graphdb/execute_script/" />
    </connectionStrings>

    <appSettings>
        <add key="EncryptIdKey" value="KeyForEncrypting"/>
        <add key="EncryptIdIV" value="IVForEncrypting1"/>
    </appSettings>
</configuration>

Examples:

Get Root Node:

Node RootNode = Node.GetRootNode();

Create a User Node with no Properties

Node nodeUser = Node.CreateNode(NodeType.User);

Create a User Node with Properties

Properties prop = new Properties();
prop.SetProperty(NodeProperty.FirstName, "Joe");
prop.SetProperty(NodeProperty.LastName, "Smith");
Node nodeUserWithName = Node.CreateNode(NodeType.User, prop);

Create Relationships to Nodes

RootNode.CreateRelationshipTo(nodeUser, RelationshipType.Likes);
RootNode.CreateRelationshipTo(nodeUserWithName, RelationshipType.Likes);

Create Relationship with Properties

Properties RelProp = new Properties();
RelProp.SetProperty(RelationshipProperty.Name, "MyRelationship");
RelProp.SetProperty("CustomRelProp", "CustomPropValue");
nodeUserWithName.CreateRelationshipTo(nodeUser, RelationshipType.Knows, RelProp);

Gremlin

Get Like relationships from the Root Node

IEnumerable<Node> LikeNodes = Gremlin.Post<Node>(RootNode.Id, "out('Likes')");

Same as above

IEnumerable<Node> SameLikeNodes = Gremlin.Post<Node>(new GremlinScript(RootNode).Out(RelationshipType.Likes.ToString()));

More Gremlin example

GremlinScript script = new GremlinScript(RootNode);
script.OutE()
        .InV()
        .OutE()
        .Filter(it => it.getProperty(RelationshipProperty.Name.ToString()) == "MyRelationship");

IEnumerable<Relationship> myRelationship = Gremlin.Post<Relationship>(script);`

Gremlin returning a datatable

GremlinScript tblScript = new GremlinScript();
tblScript.NewTable("t")
                .gV(RootNode)   
                .Out(RelationshipType.Likes.ToString())
                .As("Like")
                .Table("t", new List<string>{ "Like" })
                .Append(" >> -1; t;");

DataTable dt = Gremlin.GetTable(tblScript);

neo4jrestnet's People

Contributors

sepiagroup avatar promontis avatar

Watchers

Flavio Henrique avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.