Git Product home page Git Product logo

Comments (3)

ra0o0f avatar ra0o0f commented on May 26, 2024

@drgraduss i found a bug in resolving _to identifier and publish new nuget packages (please first upgrade https://www.nuget.org/packages/ArangoDB.Client). but i'm afraid i didn't understand the exact problem you have:

you can insert an edge with document object itself, there is no need for JObject object, an example would be:

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

        public string Fullname { get; set; }
    }

    public class Friend
    {
        [DocumentProperty(Identifier = IdentifierType.EdgeFrom)]
        public string From { get; set; }

        [DocumentProperty(Identifier = IdentifierType.EdgeTo)]
        public string To { get; set; }

        public string Message { get; set; }
    }

                var p1 = new Person { Fullname = "raoof" };
                var p2 = new Person { Fullname = "drgraduss" };

                db.Insert<Person>(p1);
                db.Insert<Person>(p2);

                var friend = new Friend { Message = "lets be friends" };

                db.InsertEdge<Friend, Person, Person>(p1.Key, p2.Key, friend);

                Debug.Assert(p1.Key != null);
                Debug.Assert(p2.Key != null);
                Debug.Assert(friend.From != null);
                Debug.Assert(friend.To != null);

if you insist using the JObject, client does not allow this yet, let me know if you need it to add support for it.

if your problem is something else please provide an example with a failing test

from arangoclient.net.

drgraduss avatar drgraduss commented on May 26, 2024

Hi @ra0o0f. Thanks for quick reply. I was using edge document to create an edge and not a JObject.
JObject snippet is from your code base which is part of InsertEdgeAsync method.

graph.InsertEdge<EdgeDocument, VerticeDocument, VerticeDocument>("_from", "_to", new EdgeDocument);

I haven't specified DocumentProperty attributes on Edge document and used plain object.

It would be good to see some documentation as it's not obvious how to map Arango's _key, _from, _to, _rev properties and if they're required to be present in the document.

from arangoclient.net.

ra0o0f avatar ra0o0f commented on May 26, 2024

you can also specify document properties mappings with DatabaseSharedSetting

// change settings for collections
sharedSetting.Collection.ChangeCollectionPropertyForType<Product>(p =>
                {
                    p.CollectionName = "products";
                    p.Naming = NamingConvention.ToCamelCase;
                });

// change default Idetntifier for `_key` property for all types
sharedSetting.Collection.ChangeIdentifierDefaultName(IdentifierType.Key, "Key");

// change default Idetntifier for `_key` property for specific type
sharedSetting.Collection.ChangeDocumentPropertyForType<Product>(p => p.productKey, s => {
                    {
                        s.Identifier = IdentifierType.Key;
                    }});

shared settings full example at DatabaseSetup

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.