DotNet4Neo4j / Neo4jClient

.NET client binding for Neo4j
https://www.nuget.org/packages/Neo4jClient
Microsoft Public License
431 stars 146 forks source link

No deep traversal when parsing expression queries #395

Closed Alexabix closed 3 years ago

Alexabix commented 3 years ago

I've written a method to create relationships that accepts generic types and I'm getting a NotSupportedException with the message

Unhandled node type MemberAccess in MemberExpression: Convert(value(Graph.WriteService+<>c__DisplayClass10_02[Graph.Nodes.Journey,Graph.Nodes.UserPath]).sourceNode, INode).Id`

It looks like the previously fixed issue mentioned here is back

https://stackoverflow.com/questions/19111052/node-byindexlookup-and-where-clause-throwing-exception

Here is the function throwing an exception, the fix is commented out.

        private async Task RelateTwoNodesIfNotReleated<TSource, TTarget>(TSource sourceNode, string relationshipName, TTarget targetNode)
            where TSource : INode where TTarget : INode
        {
            try
            {
                //var sourceId = sourceNode.Id;
                //var targetId = targetNode.Id;

                //var debugText = graphClient.Cypher
                //    .Match($"(source:{typeof(TSource).Name})")
                //    .Match($"(target:{typeof(TTarget).Name})")
                //    .Where((TSource source) => source.Id == sourceId)
                //    .AndWhere((TTarget target) => target.Id == targetId)
                //    .Create($"(source)-[:{relationshipName.ToUpper()}]->(target)").Query.DebugQueryText;

                await graphClient.Cypher
                .Match($"(source:{typeof(TSource).Name})")
                .Match($"(target:{typeof(TTarget).Name})")
                .Where((TSource source) => source.Id == sourceNode.Id)
                .AndWhere((TTarget target) => target.Id == targetNode.Id)
                .Create($"(source)-[:{relationshipName.ToUpper()}]->(target)").ExecuteWithoutResultsAsync();

            }
            catch (Exception ex2)
            {
                throw;
            }
        }

The INode interface just defines a Guid called Id

cskardon commented 3 years ago

Hello,

Please can you supply the following:

Versions:

Thanks

Alexabix commented 3 years ago
cskardon commented 3 years ago

Awesome thank you! I'll have a look and see what I can see

cskardon commented 3 years ago

This should be in the next version (4.1.5) - obvs - reopen if it's not fixed :/