Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return result as anonymous object issue. #348

Open
alexanderIT opened this issue Feb 11, 2020 · 2 comments
Open

Return result as anonymous object issue. #348

alexanderIT opened this issue Feb 11, 2020 · 2 comments

Comments

@alexanderIT
Copy link

alexanderIT commented Feb 11, 2020

Hi ,

I have ran into the following issue: when I execute query that return result in anonymous object :

var query = this.GraphClient.Cypher
.Match($"(e:{SystemNodeLabelEnum.Product.ToString()} {{AccountId: "{accountId}"}})")
.Return(e => new { SystemNode = e.As<SystemNode>() })
.OrderBy("e.ProductDistributorId")
.Skip(offset)
.Limit(limit);

this query throw exception:

Exception:
Exception has been thrown by the target of an invocation.
Inner exception:
Conversion of ZonedDateTime to INode is not supported.
at Neo4j.Driver.V1.TemporalValue.System.IConvertible.ToType(Type conversionType, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) in //src/System.Private.CoreLib/shared/System/Convert.cs:line 377
at System.Convert.ChangeType(Object value, Type conversionType) in /
/src/System.Private.CoreLib/shared/System/Convert.cs:line 315
at Neo4j.Driver.V1.ValueExtensions.As[T](Object value)
at Neo4jClient.StatementResultHelper.Parse[T](IRecord record, String identifier, IGraphClient graphClient)

When i have changed the return type to be the concrete object (not anonymous ) as following:

public class SystemNodeContainer
{
public SystemNode Node { get; set; }
}

the same query execute properly and return the correct result.

var query = this.GraphClient.Cypher
.Match($"(e:{SystemNodeLabelEnum.Product.ToString()} {{AccountId: "{accountId}"}})")
.Return(e => new SystemNodeContainer { SystemNode = e.As<SystemNode>() })
.OrderBy("e.ProductDistributorId")
.Skip(offset)
.Limit(limit);

Could you please advise?

@alexanderIT alexanderIT changed the title Map Id and Label from Neo4j to c# poco object. Return result as anonymous object issue. Feb 12, 2020
@alexanderIT
Copy link
Author

One of the properties in my custom class SystemNode is of type DateTime and in the neo4j database the relevant property is of type datetime and lookes like that : "2020-02-13T09:29:20.4700000"
I have debugged the BoltGraphClient source code and found that when ParseAnonymousAsDynamic method from StatementResultHelper class in client attempt to parse the datetime property from database throw the exception described in the post above.
When i have changed the type of datetime property in the neo4j graph ti string the problem was solved and anonymouse parser work properly.

Could you please advise me what should be the type of datetime property in neo4j database to work properly the deserializer.

@cskardon
Copy link
Member

Hey - sorry for the delay in replying, can you provide the SystemNode class - or just how the property that is failing is defined?

It's possible that PR #392 solves this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants