コード例 #1
0
        /// <summary>
        /// Gets or creates a "person".
        ///
        /// This step first checks for existence of a person given their identifier. If it exists then the person is
        /// returned and their "name" property updated. It is not possible to change the person's identifier once it is
        /// assigned (at least as defined by this DSL). If the person does not exist then a new person vertex is added
        /// with the specified identifier and name.
        /// </summary>
        public static GraphTraversal <S, Vertex> Person <S, E>(this GraphTraversal <S, E> t, string personId, string name)
        {
            if (string.IsNullOrEmpty(personId))
            {
                throw new ArgumentException("The personId must not be null or empty");
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("The name of the person must not be null or empty");
            }

            return(t.Coalesce <Vertex>(__.V().Has(VertexPerson, KeyPersonId, personId),
                                       __.AddV(VertexPerson).Property(KeyPersonId, personId)).
                   Property(KeyName, name));
        }