Gremlinq / ExRam.Gremlinq

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Complex Objects as Properties of Vertices

javaadpatel opened this issue · comments

Hi, is there a way to store complex objects as properties of vertices, something like this:

 public class IdentityRole : UserStoreVertex
    {
        public IdentityRole()
        {
        }

        [JsonProperty(PropertyName = "name")]
        public string Name { get; set; }

        [JsonProperty(PropertyName = "normalizedName")]
        public string NormalizedName { get; set; }

        [JsonProperty(PropertyName = "claims")]
        public Claim[] Claims { get; set; } 
    }

when i try to add these I get an error

ActivityId : 965e7378-fe8f-4796-8f1d-afe028159fb2
ExceptionType : ArgumentException
ExceptionMessage :
	The elements in the list are of constant type. Cannot bind complex values to constant groovy values.
	Parameter name: value
Source : Microsoft.Azure.Cosmos.Gremlin.Core
	HResult : 0x80070057

Is there a way to do this? I also tried using the Meta property with something like this:

    public class IdentityRole : UserStoreVertex
    {
        public IdentityRole()
        {
            this.Claims = new VertexProperty<string, ClaimMeta>("claims");
            //this.Claims.Properties.Creator = "tylor";
        }

        [JsonProperty(PropertyName = "name")]
        public string Name { get; set; }

        [JsonProperty(PropertyName = "normalizedName")]
        public string NormalizedName { get; set; }

        [JsonProperty(PropertyName = "claims")]
        public VertexProperty<string, ClaimMeta> Claims { get; set; } 
    }
    public class ClaimMeta
    {
        public string Creator { get; set; }
        public Claim Claim { get; set; }
        public DateTimeOffset Date { get; set; }
    }

I figured i can serialized the complex object and store it as a string but I don't think I'd then be able to do filtering on it.

Unfortunately, no. As you said, you can always serialize a complex object but there is no intent for an automatic approach in ExRam.Gremlinq.

Okay I see, thank you very much, I guess this is just a data modelling issue so I've changed how my data was modelled now