Skip to content

Annotating a property of type Guid as DocumentProperty.Key throws InvalidCastException #128

@TommyEmmanuel

Description

@TommyEmmanuel

As the title suggests, I have had all my class Id properties decorated with
[DocumentProperty(Identifier = IdentifierType.Key)]
All Id properties are of type System.Guid and thus far had no issues with it.
As a matter of fact, i used a generic base type to get any type on Id property on all my entities.

        public abstract class BaseEntity<TId> : IEntity<TId>
        {
            [DocumentProperty(Identifier = IdentifierType.Key)]
            [DataMember(Name = "id")]
            public TId Id { get; set; }
        }

and it worked wonderfully.
I have been using this originally in the prior version v0.7.6.
Since the update, I've been getting InvalidCastException with the message:

Unable to cast object of type 'System.String' to type 'System.Guid'.

The exception happens somewhere within a lambda expression and the closest to the line of code where i have been able to investigate is:
ArangoDB.Client.Property.DocumentIdentifierModifier in the line 55
This line tries to generically create a SetValue (there is even a stackoverflow link attached)

I have also tried cloning the project and updating all the nuget references thinking it would help, but no progress there.

This breaking change happened with the updated version v0.7.70.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions