Gremlinq / ExRam.Gremlinq

A .NET object-graph-mapper for Apache TinkerPop™ Gremlin enabled databases.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support declarative label name for schema bound graph element

veeg opened this issue · comments

Add support for the IVertex model to provide the label name in the graph. Currently, the label name is derived from the type name.

See equivalent functionality in Gremlin.Net.CosmosDb

Example:

[Label("user")]
public class User : Vertex
{
}

// The vertices in the graph has the label "user", not "User".
let result = await g.v<User>.ToArray();

Have a look at the changes in this commit. It allows you to modify your model to make all labels lowercase. What do you think of it?

I'm currently not sure whether to go for the attribute solution, at least not out-of-the-box, since there is always a possibility that developers not have access to the source of the used POCOs.

However, that doesn't mean that there cannot be a separate library, either 3rd party or within the Gremlinq solution, that would provide support for annotiations through attributes. Gremlinqs IGraphModel-approach definitely allows this.

It is certainly an improvement that would fulfill my current use-case.

I have no strong opinions on either solutions, as long as there is some solution to modify the derivative of types into graph labels.

There'll be a new minor release next week.

Just released version a new version of Gremlinq: https://www.nuget.org/packages/ExRam.Gremlinq.Core/6.4.1.

You can now use WithLowercaseLabels on your IGraphModel. Unfortunately, there are no extension points yet to have properties in lower case. I might consider this in a future major release. Ideas and PRs are always welcome!