Git Product home page Git Product logo

Comments (4)

ra0o0f avatar ra0o0f commented on May 26, 2024

@danludwig yes this is a bug, i should look into it. but for now you can use [JsonIgnore] json.net attribute for ignoring members

just be aware you should use embeded json.net
[ArangoDB.Client.Common.Newtonsoft.Json.JsonIgnore]

and you dont need JsonIgnore on overrided members

public abstract class ContactInfo
    {
        public SomeEnum SomeEnumValue { get; set; }
        [JsonIgnore]
        public abstract string ContactValue { get; }
    }

    public class ContactEmailInfo : ContactInfo
    {
        public string EmailAddress { get; set; }
        public override string ContactValue => EmailAddress;
    }

    public class ContactPhoneInfo : ContactInfo
    {
        public ulong PhoneNumber { get; set; }
        public string RegionCode { get; set; }
        public override string ContactValue => RegionCode;
    }

    public class UserDocument
    {
        public UserDocument()
        {
            ContactEmails = new List<ContactEmailInfo>();
            ContactPhones = new List<ContactPhoneInfo>();
        }
        public IList<ContactEmailInfo> ContactEmails { get; }
        public IList<ContactPhoneInfo> ContactPhones { get; }

        [JsonIgnore]
        public IReadOnlyCollection<ContactInfo> ContactInfos =>
          new ReadOnlyCollection<ContactInfo>(ContactEmails
            .Cast<ContactInfo>().Union(ContactPhones).ToArray());
    }

from arangoclient.net.

danludwig avatar danludwig commented on May 26, 2024

Perfect, that is what I was looking for. Knowing about the embedded JSON.NET also helped me serialize enum values as string instead of int, using

[ArangoDB.Client.Common.Newtonsoft.Json.JsonConverter(typeof(ArangoDB.Client.Common.Newtonsoft.Json.Converters.StringEnumConverter))]
public SomeEnum SomeEnumValue { get; set; }

from arangoclient.net.

ra0o0f avatar ra0o0f commented on May 26, 2024

let the issue be open till the bug is resolved

from arangoclient.net.

Jenar78 avatar Jenar78 commented on May 26, 2024

In current version (v0.7.60) still having this issue + new problem.
[ArangoDB.Client.Common.Newtonsoft.Json.JsonIgnore] can't be used because new ArangoDB has no "Common" namespace so i have used only [Newtonsoft.Json.JsonIgnore] which worked for some properties.
New problem:
i have following class (for tesing ArangoDB vs MongoDB:
`using ArangoDB.Client; //Nuget: ArangoDB.Client by raoof hojat v0.7.60
using MongoDB.Bson; //Nuget: MongoDB.Driver by MongoDB, Inc v2.3.0

public class Person
{
[DocumentProperty(Identifier = IdentifierType.Key)]
public string Key { get; set; }
public string Fullname { get; set; }
public int Age { get; set; }

    // MongoDB
    [DocumentProperty(IgnoreProperty = true)]//ignore for ArangoDB - not working - bug https://github.com/ra0o0f/arangoclient.net/issues/34
   [Newtonsoft.Json.JsonIgnore] // proposed workaround for ArangoDB
    public MongoDB.Bson.ObjectId _id { get; set; }

}`
and i whanted ArangoDB to ignore "_id"

but after
db.Insert<Person>(person);
i am catching an exception "Unable to cast object of type 'System.String' to type 'MongoDB.Bson.ObjectId'."
Callstack:
at lambda_method(Closure , Object , Object ) at ArangoDB.Client.Property.DocumentIdentifierModifier.Modify(Object document, IDocumentIdentifierResult identifiers) at ArangoDB.Client.Collection.ArangoCollection.<InsertAsync>d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at ArangoDB.Client.Collection.ArangoCollection1.d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at ArangoDB.Client.Utility.TaskUtils.ResultSynchronizer[T](Task1 task)
Also this workaround is not working in all cases.
Is there any chance to fix this bug, because i want to give ArangoDB the chance ;) ?

from arangoclient.net.

Related Issues (20)

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.