Giter Site home page Giter Site logo

rexpro-client's Introduction

rexpro-client

RexPro Client for .NET

Install

To install .NET RexPro Client, run the following command in the NuGet Package Manager Console:

PM> Install-Package RexProClient

Getting started

First create a simple class to hold some vertex data.

[DataContract]
public class Example
{
    [DataMember(Name = "name")]
    public string Name { get; set; }
}

That's it. Now fire up some queries.

Queries without return value (null)

var client = new RexProClient();

client.Query("g.addVertex(['name':'foo']); null");

// same query with parameter binding
var bindings = new Dictionary<string, object> {{ "name", "foo" }};
client.Query("g.addVertex(['name':name]); null", bindings);

Queries with scalar return value

var result = client.Query<long>("g.V.count()");

Queries with complex return value

// not really different from scalar return values
var bindings = new Dictionary<string, object> {{ "name", "foo" }};
var result = client.Query<Vertex<Example>>("g.addVertex(['name':name])", bindings);

Queries with sessions

using (var session = client.StartSession())
{
    client.Query("number = 1 + 2", session);
    var result = client.Query<int>("number", session);
}

Dynamic queries

var res1 = client.Query("1 + 2");
var res2 = client.Query("g.addVertex(['foo':'bar'])")
var res3 = client.Query("g.addVertex(['lorem':'ipsum']).map()")
var vertices = client.Query<dynamic[]>("g.V");
var idQuery =
    from vertex in vertices
    select vertex.Id;

Console.WriteLine("1 + 2 = {0}", res1);
Console.WriteLine("foo vertex id: {0}", res2.Id);
Console.WriteLine("lorem: {0}", res3.lorem);
Console.WriteLine("vertex ids: {0}", string.Join(",", idQuery));

Use vertex in bindings

using (var session = client.StartSession())
{
    var v1 = client.Query("g.addVertex()", session: session);
    var v2 = client.Query("g.addVertex()", session: session);
    var bindings = new Dictionary<string, object>
    {
        { "v1", v1 },
        { "v2", v2 },
        { "label", "knows" }
    };

    client.Query("g.addEdge(g.v(v1), g.v(v2), label)", bindings, session);

Run unit tests

To run the unit tests, you first need to adjust the settings for your RexPro server. In Visual Studio go to the projects application settings and customize the values for the fields RexProHost and RexProPort.

rexpro-client's People

Contributors

dkuppitz avatar zachkinstner avatar

Watchers

James Cloos avatar Ross Mills 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.