Stardust.Paradox.Data 1.4.9

Entityframework styled tool for accessing gremlin based graph databases like CosmosDB and Apache Tinkerpop

There is a newer prerelease version of this package available.
See the version list below for details.
Install-Package Stardust.Paradox.Data -Version 1.4.9
dotnet add package Stardust.Paradox.Data --version 1.4.9
paket add Stardust.Paradox.Data --version 1.4.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Usage (asp.net core)

Startup.cs

ConfigureServices

Add the generated entity implementations to the IOC container (I will provide an extention method to make this easier)

 services.AddEntityBinding((entityType, entityImplementation) => services.AddTransient(entityType, entityImplementation))
        .AddScoped<MyEntityContext,MyEntityContext>()
        .AddScoped<IGremlinLanguageConnector>(s => new CosmosDbLanguageConnector(DbAccountName, AccessKey, "databaseName","collectionName"));

Defining the model

[VertexLabel("person")]
public interface IPerson : IVertex
{
    string Id {get;}

    string FirstName { get; set; }

    string LastName { get; set; }
    
    string Email { get; set; }

    IEdgeCollection<IPerson> Parents { get; }

    IEdgeCollection<IPerson> Children { get; }

    IEdgeCollection<IPerson> Siblings { get; }

    [EdgeLabel("city")] //pointing to the Residents property in ICity
    IEdgeReference<ICity> HomeCity { get; }//use IEdgeReference to enable task-async operations

    IEdgeCollection<ICompany> Employers { get; }
}

[VertexLabel("city")]
public interface ICity : IVertex
{
    string Id { get; }

    string Name { get; set; }

    string ZipCode { get; set; }
    

   [ReverseEdgeLabel("city")] //pointing to the HomCity property in IPerson
    IEdgeCollection<Iperson> Residents { get; } //use IEdgeCollection to enable task-async operations on the collection

    IEdgeReference<ICountry> Country { get; }
}

[VertexLabel("company")]
public interface ICompany : IVertex
{
    string Id { get; }

    string Name { get; set; }

    IEdgeCollection<ICompany> Employees { get; }
}

[VertexLabel("country")]
public interface ICountry : IVertex
{
    string Id { get; }

    string Name { get; set; }

    string CountryCode { get; set; }

    string PhoneNoPrefix { get; set; }

    IEdgeCollection<ICity> Cities { get; }
}

Defining the entity context and generating the entity implementations

public class MyEntityContext : Stardust.Paradox.Data.GraphContextBase
{
    public IGraphSet<IPerson> Persons => GraphSet<IPerson>();

    public IGraphSet<ICity> Cities => GraphSet<ICity>();

    public IGraphSet<ICountry> Countries => GraphSet<ICountry>();

    public IGraphSet<ICompany> Companies => GraphSet<ICompany>();

    public MyEntityContext(IGremlinLanguageConnector connector, IServiceProvider resolver) : base(connector, resolver)
    {
    }

    protected override bool InitializeModel(IGraphConfiguration configuration)
    {
        //Added some fluent configuration of the edges
        configuration.ConfigureCollection<IPerson>()
                .AddEdge(t => t.Children, "children").Reverse<IPerson>(t => t.Parents)
            .ConfigureCollection<ICity>()
            .ConfigureCollection<ICountry>()
                .AddEdge(t=>t.Cities).Reverse<ICountry>(t=>t.Country)
            .ConfigureCollection<ICompany>()
                .AddEdge(t => t.Employees, "employees").Reverse<IPerson>(t => t.Employers);
        return true;
    }
}

Usage (asp.net core)

Startup.cs

ConfigureServices

Add the generated entity implementations to the IOC container (I will provide an extention method to make this easier)

 services.AddEntityBinding((entityType, entityImplementation) => services.AddTransient(entityType, entityImplementation))
        .AddScoped<MyEntityContext,MyEntityContext>()
        .AddScoped<IGremlinLanguageConnector>(s => new CosmosDbLanguageConnector(DbAccountName, AccessKey, "databaseName","collectionName"));

Defining the model

[VertexLabel("person")]
public interface IPerson : IVertex
{
    string Id {get;}

    string FirstName { get; set; }

    string LastName { get; set; }
    
    string Email { get; set; }

    IEdgeCollection<IPerson> Parents { get; }

    IEdgeCollection<IPerson> Children { get; }

    IEdgeCollection<IPerson> Siblings { get; }

    [EdgeLabel("city")] //pointing to the Residents property in ICity
    IEdgeReference<ICity> HomeCity { get; }//use IEdgeReference to enable task-async operations

    IEdgeCollection<ICompany> Employers { get; }
}

[VertexLabel("city")]
public interface ICity : IVertex
{
    string Id { get; }

    string Name { get; set; }

    string ZipCode { get; set; }
    

   [ReverseEdgeLabel("city")] //pointing to the HomCity property in IPerson
    IEdgeCollection<Iperson> Residents { get; } //use IEdgeCollection to enable task-async operations on the collection

    IEdgeReference<ICountry> Country { get; }
}

[VertexLabel("company")]
public interface ICompany : IVertex
{
    string Id { get; }

    string Name { get; set; }

    IEdgeCollection<ICompany> Employees { get; }
}

[VertexLabel("country")]
public interface ICountry : IVertex
{
    string Id { get; }

    string Name { get; set; }

    string CountryCode { get; set; }

    string PhoneNoPrefix { get; set; }

    IEdgeCollection<ICity> Cities { get; }
}

Defining the entity context and generating the entity implementations

public class MyEntityContext : Stardust.Paradox.Data.GraphContextBase
{
    public IGraphSet<IPerson> Persons => GraphSet<IPerson>();

    public IGraphSet<ICity> Cities => GraphSet<ICity>();

    public IGraphSet<ICountry> Countries => GraphSet<ICountry>();

    public IGraphSet<ICompany> Companies => GraphSet<ICompany>();

    public MyEntityContext(IGremlinLanguageConnector connector, IServiceProvider resolver) : base(connector, resolver)
    {
    }

    protected override bool InitializeModel(IGraphConfiguration configuration)
    {
        //Added some fluent configuration of the edges
        configuration.ConfigureCollection<IPerson>()
                .AddEdge(t => t.Children, "children").Reverse<IPerson>(t => t.Parents)
            .ConfigureCollection<ICity>()
            .ConfigureCollection<ICountry>()
                .AddEdge(t=>t.Cities).Reverse<ICountry>(t=>t.Country)
            .ConfigureCollection<ICompany>()
                .AddEdge(t => t.Employees, "employees").Reverse<IPerson>(t => t.Employers);
        return true;
    }
}

Release Notes

1.3: Added fluent configuration of edge references
1.3: Added basic Edge properties support
1.4: Performance improvements and bugfixes
1.4.6: Updated to use the new symbol package format
1.4.7: Fixed confusing parameter naming for Range step and added a SkipTake step to help witn pagination

Version History

Version Downloads Last updated
2.0.0-pre26 20 2/14/2019
2.0.0-pre23 28 2/12/2019
2.0.0-pre15 31 2/6/2019
2.0.0-pre11 33 2/4/2019
2.0.0-pre09 55 1/25/2019
2.0.0-pre02 42 1/16/2019
2.0.0-pre01 100 12/5/2018
1.4.9 30 2/8/2019
1.4.8 135 12/6/2018
1.4.7 82 11/28/2018
1.4.5 69 11/21/2018
1.4.4 83 11/20/2018
1.4.3 103 11/6/2018
1.4.1 78 10/30/2018
1.4.0 85 10/22/2018
1.3.11 73 10/16/2018
1.3.5 89 10/15/2018
1.3.4 146 10/8/2018
1.3.3 138 10/2/2018
1.3.2 106 9/11/2018
1.3.1 169 8/23/2018
1.3.0 93 8/23/2018
1.2.0 87 8/20/2018
1.1.5 93 8/15/2018
1.0.4 85 8/14/2018
1.0.3 83 8/13/2018
1.0.2 82 8/13/2018
1.0.1 84 8/10/2018
1.0.0-pre005 163 7/3/2018
1.0.0-pre001 119 6/11/2018
Show less