2014-02-12 2 views
0

Попытки использовать Neo4jClient, получить это исключение, говоря, что он не мог справиться в противном случае правильного ответа от Neo4j:Другого исключения брошенного Neo4jclient

{"Neo4j returned a valid response, however Neo4jClient was unable to deserialize into the object structure you supplied. 

First, try and review the exception below to work out what broke. 

If it's not obvious, you can ask for help at http://stackoverflow.com/questions/tagged/neo4jclient 

Include the full text of this exception, including this message, the stack trace, and all of the inner exception details. 

Include the full type definition of MyStory.Logic.DbUpdateSlice.Model.DbUpdate. 

Include this raw JSON, with any sensitive values replaced with non-sensitive equivalents: 

{ 
    \"columns\" : [ \"dbUpdates\" ], 
    \"data\" : [ [ { 
    \"outgoing_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/out\", 
    \"data\" : { 
     \"UpdateStart\" : \"2014-10-24T15:30:23\", 
     \"UpdateMethodName\" : \"abc.def\", 
     \"DbUpdateState\" : \"Running\", 
     \"UniqueId\" : 1 
    }, 
    \"traverse\" : \"http://127.255.0.0:20001/db/data/node/853098/traverse/{returnType}\", 
    \"all_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/all/{-list|&|types}\", 
    \"property\" : \"http://127.255.0.0:20001/db/data/node/853098/properties/{key}\", 
    \"self\" : \"http://127.255.0.0:20001/db/data/node/853098\", 
    \"properties\" : \"http://127.255.0.0:20001/db/data/node/853098/properties\", 
    \"outgoing_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/out/{-list|&|types}\", 
    \"incoming_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/in\", 
    \"extensions\" : { 
    }, 
    \"create_relationship\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships\", 
    \"paged_traverse\" : \"http://127.255.0.0:20001/db/data/node/853098/paged/traverse/{returnType}{?pageSize,leaseTime}\", 
    \"all_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/all\", 
    \"incoming_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/in/{-list|&|types}\" 
    } ], [ { 
    \"outgoing_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/out\", 
    \"data\" : { 
     \"UpdateStart\" : \"2014-11-04T01:32:23\", 
     \"UpdateMethodName\" : \"xyz.123.987\", 
     \"DbUpdateState\" : \"Failed\", 
     \"UniqueId\" : 2 
    }, 
    \"traverse\" : \"http://127.255.0.0:20001/db/data/node/853099/traverse/{returnType}\", 
    \"all_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/all/{-list|&|types}\", 
    \"property\" : \"http://127.255.0.0:20001/db/data/node/853099/properties/{key}\", 
    \"self\" : \"http://127.255.0.0:20001/db/data/node/853099\", 
    \"properties\" : \"http://127.255.0.0:20001/db/data/node/853099/properties\", 
    \"outgoing_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/out/{-list|&|types}\", 
    \"incoming_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/in\", 
    \"extensions\" : { 
    }, 
    \"create_relationship\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships\", 
    \"paged_traverse\" : \"http://127.255.0.0:20001/db/data/node/853099/paged/traverse/{returnType}{?pageSize,leaseTime}\", 
    \"all_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/all\", 
    \"incoming_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/in/{-list|&|types}\" 
    } ] ] 
} 
Parameter name: content"} 

Определение DbUpdate

public class DbUpdate 
{ 
    public long UniqueId { get; set; } 
    public string UpdateMethodName { get; set; } 
    public DateTime? UpdateStart { get; set; } 
    public DateTime? UpdateEnd { get; set; } 
    public DbUpdateState DbUpdateState { get; set; } 
} 

Код фактического сообщения:

 var dbUpdate1 = new DbUpdate() 
     { 
      UpdateMethodName = "abc.def", 
      UpdateStart = new DateTime(2014, 10, 24, 15, 30, 23), 
      UpdateEnd = null, 
      DbUpdateState = DbUpdateState.Running 
     }; 

     long dbUpdate1UniqueId = dbUpdateRepository.CreateDbUpdate(dbUpdate1); 

     var dbUpdates = dbUpdateRepository.GetAllDbUpdates().ToList(); 

< < < < < исключение брошено внутри этот способ. Смотри ниже.


класс репо, который содержит методы, вызываемые из тестового кода:

public class DbUpdateRepository: IDbUpdateRepository 
{ 
    readonly IGraphClient graphClient; 
    readonly IMyStoryUserPrincipal principal; 
    readonly IMyStoryUniqueIdGenerator uniqueIdGenerator; 

    public DbUpdateRepository (
     IMyStoryUserPrincipal principal, 
     IGraphClient graphClient, 
     IMyStoryUniqueIdGenerator uniqueIdGenerator) 
    { 
     this.principal = principal; 
     this.graphClient = graphClient; 
     this.uniqueIdGenerator = uniqueIdGenerator; 
    } 

    public IEnumerable<DbUpdate> GetAllDbUpdates() 
    { 
     var query = graphClient 
      .RootNode 
      .StartCypher("root") 
      .Match("root-[:" + HasDbUpdates.TypeKey + "]-dbUpdates") 
      .Return(dbUpdates => dbUpdates.As<DbUpdate>()); 

     return query.Results;  <<<<< exception thrown here 
    } 


    public long CreateDbUpdate (DbUpdate dbUpdate) 
    { 
     dbUpdate.UniqueId = uniqueIdGenerator.NextDbUpdateId(); 

     graphClient.Create(dbUpdate, 
          new HasDbUpdates(graphClient.RootNode) 
          { 
           Direction = RelationshipDirection.Incoming 
          }); 

     return dbUpdate.UniqueId; 
    } 
} 

ответ

1

Оказывается, что Neo4jClient не может справиться с DateTime. Вы должны использовать DateTimeOffset.

+0

Да. На самом деле должно быть хорошее сообщение об этом во внутреннем исключении, но внешнее исключение маскирует его из памяти. –

+0

Зачем бросать исключение? Почему бы просто не поддерживать DateTime? Это спасет много людей. – user1147862

+0

Это не поддерживается только потому, что я никогда не нуждался в нем или не написал его. Когда библиотека попадает под неподдерживаемый тип, она терпит неудачу с исключением вместо молча. Если вы подключаетесь к «IGraphClient.JsonConverters» или отправляете запрос на перенос в библиотеку, вы можете заставить его работать с любым типом. –

Смежные вопросы