问题描述
我正在尝试将 C# DateTime 属性存储为原生 Neo4j DATE_TIME
,但它们始终存储为 STRING
。
简化示例代码:
// properties
IDictionary<string,dynamic> parameterMapCreate = new Dictionary<string,dynamic>();
parameterMapCreate.Add("createdAt",Datetime.UtcNow);
// labels
var labelsToAdd = "Label01:Label02";
// query
var cypherQuery = _graphClient.Cypher
.WithParams(new
{
tok = Guid.NewGuid(),propertiesCreate = parameterMapCreate
})
.Merge($"(n:{"TestNodeLabel"} {{ {"token"}: $tok }})")
.OnCreate().Set("n = $propertiesCreate")
.Set("n:" + labelsToAdd)
.With("n,properties(n) as prop")
.Returndistinct((n,prop) => new GenericNode
{
Id = n.Id(),Labels = n.Labels(),Properties = prop.As<Dictionary<string,string>>(),});
// generic node (doesn't affect storage type,only what we get back)
public class GenericNode
{
public long Id { get; set; }
public IEnumerable<string> Labels { get; set; }
public Dictionary<string,string> Properties { get; set; }
}
数字和布尔类型存储正确,但日期存储为 STRING
,如以下查询所示:
MATCH (n)
WITH (apoc.Meta.cypher.types(n)) as types
return types
给出:
types
{
"createdAt": "STRING","token": "STRING"
}
我看到使用自定义 POCO 我们可以用 [Neo4jDateTime]
属性装饰属性,但是如果我们没有固定的类/属性并且只想通过字典传递一堆属性,如图所示怎么办?
谢谢, 理查德
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)