Re: Serializing/Deserialzing Collections of properties using .NET and the Neo4jClient

170 views
Skip to first unread message

Yuquan Wang

unread,
Apr 17, 2014, 7:58:43 AM4/17/14
to ne...@googlegroups.com
Hi,wilsonjan.
I also met the problem.Did you solve it?

在 2013年2月8日星期五UTC+8下午4时06分41秒,wilsonjan写道:
I'm using the Neo4jClient to create nodes in neo4j and would like to know if there is a way to serialize and deserialize objects against .net types which contain dictionaries to hold values for all the node properties.  The reason for this is that the number of properties can vary over time.

For example, I'd like to be able to do the following:

public class Order
{
    public int OrderId { get; set; }
    public Dictionary<string, string> Attributes { get; set; }
}

When (using the Neo4jClient) I read in the value of a node and convert it to an Order type, each property in the node will get added to the dictionary of Attributes.

Likewise, when I save an object of this structure I need be able to extract all the values in the Attributes dictionary and generate against the node for each property.


marouane denguiri

unread,
Apr 18, 2014, 7:47:02 AM4/18/14
to ne...@googlegroups.com
Hi All,
the same problem , i don't know how to resolve it...
I have a Dictionary  that hold  2 kinds  of objects ( Documents and there words):
  Dictionary<Document, List<Concept>> lista = new Dictionary<Document, List<Concept>>()
i'am using neo4jClient , i read that it possible to make it with cypher query (foreach) , but i didn't solve it

and i want to create a neo4j graph  using this Dictionary

Kenny Bastani

unread,
Apr 18, 2014, 8:05:42 PM4/18/14
to ne...@googlegroups.com

This is more of a .NET exercise in how to deserialize objects into a collection and then map those values to a dictionary.

For example, here is a response via the Cypher REST API:

{
  "columns" : [ "n" ],
  "data" : [ [ {
    "labels" : "http://localhost:7474/db/data/node/44/labels",
    "outgoing_relationships" : "http://localhost:7474/db/data/node/44/relationships/out",
    "data" : {
      "position" : "Developer",
      "awesome" : true,
      "name" : "Michael",
      "children" : 3
    },
    "traverse" : "http://localhost:7474/db/data/node/44/traverse/{returnType}",
    "all_typed_relationships" : "http://localhost:7474/db/data/node/44/relationships/all/{-list|&|types}",
    "property" : "http://localhost:7474/db/data/node/44/properties/{key}",
    "self" : "http://localhost:7474/db/data/node/44",
    "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/44/relationships/out/{-list|&|types}",
    "properties" : "http://localhost:7474/db/data/node/44/properties",
    "incoming_relationships" : "http://localhost:7474/db/data/node/44/relationships/in",
    "extensions" : {
    },
    "create_relationship" : "http://localhost:7474/db/data/node/44/relationships",
    "paged_traverse" : "http://localhost:7474/db/data/node/44/paged/traverse/{returnType}{?pageSize,leaseTime}",
    "all_relationships" : "http://localhost:7474/db/data/node/44/relationships/all",
    "incoming_typed_relationships" : "http://localhost:7474/db/data/node/44/relationships/in/{-list|&|types}"
  } ] ]
}

Now deserialize this into .NET objects. Each key is a column and each data are the values.

It's not possible to do this with Neo4jClient, so you'll need to write your own extension of Neo4jClient to handle this using serialization. I recommend using http://json2csharp.com/ to generate your .NET objects from JSON.

Thanks,

Kenny
Reply all
Reply to author
Forward
0 new messages