Neo4J Readify客户端/驱动程序:无法反序列化对象

时间:2015-11-12 12:35:38

标签: neo4j neo4jclient

我在尝试通过运行以下方法获取结果集时收到错误/异常:

public IEnumerable<NeoProduct> GetAllProductsUnderCategory(int categoryId)
                 {
             var query = neo.Cypher.Match("(c:Category{CategoryId:{id}})<-[*](p:Product)")
    .WithParam("id", categoryId)
    .Return(p => p.As<NeoProduct>()).Results;
            }

正如您所看到的,它是一个返回NeoProducts列表的非常简单的方法。 NeoProduct是一个简单的POCO,具有以下属性:

public int CategoryId { get; set; }
    public string CategoryName { get; set; }
    public int ParentCategoryId { get; set; }

堆栈跟踪是:

   [OverflowException: Value was either too large or too small for an Int64.]
       System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt) +14278344
       System.String.System.IConvertible.ToInt64(IFormatProvider provider) +55
       System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +14285879
       Neo4jClient.Serialization.CommonDeserializerMethods.CoerceValue(DeserializationContext context, PropertyInfo propertyInfo, JToken value, IEnumerable`1 typeMappings, Int32 nestingLevel) in D:\temp\tmpC806\Neo4jClient\Serialization\CommonDeserializerMethods.cs:101
       Neo4jClient.Serialization.CommonDeserializerMethods.Map(DeserializationContext context, Object targetObject, JToken parentJsonToken, IEnumerable`1 typeMappings, Int32 nestingLevel) in D:\temp\tmpC806\Neo4jClient\Serialization\CommonDeserializerMethods.cs:365
       Neo4jClient.Serialization.CommonDeserializerMethods.CreateAndMap(DeserializationContext context, Type type, JToken element, IEnumerable`1 typeMappings, Int32 nestingLevel) in D:\temp\tmpC806\Neo4jClient\Serialization\CommonDeserializerMethods.cs:303
       Neo4jClient.Serialization.<>c__DisplayClass17_0.<ParseInSingleColumnMode>b__1(JToken row) in D:\temp\tmpC806\Neo4jClient\Serialization\CypherJsonDeserializer.cs:437
       System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +223
       System.Linq.Buffer`1..ctor(IEnumerable`1 source) +264
       System.Linq.Enumerable.ToArray(IEnumerable`1 source) +106
       Neo4jClient.Serialization.CypherJsonDeserializer`1.Deserialize(String content) in D:\temp\tmpC806\Neo4jClient\Serialization\CypherJsonDeserializer.cs:64
   [ArgumentException: Neo4j returned a valid response, however Neo4jClient was unable to deserialize into the object structure you supplied.

对于方法,我传递的参数返回一个包含900个实体的结果集(结果来自Neo4J浏览器)。否则,该方法似乎按预期工作。

我怀疑JSON对象对于内部反序列化器来说太大了。有人有这个问题吗?

1 个答案:

答案 0 :(得分:5)

我发现了这个问题。数据库中有一个实体,它的数字很大,大于int64,导致反序列化器抛出异常(试图将大于int64的数字插入到int64属性中)。

今天的教训:确保数据符合模型:)