I\'m following this little write up: https://github.com/Readify/Neo4jClient/wiki/cypher but I\'m doing it from Powershell. so what I have so far is
[System.
There are two problems with Return method:
ScriptBlock. So, you have to create expression tree by hands or use string overload.string overload does not allows PowerShell to infer generic parameter for method, and PowerShell syntax does not allows to specifying generic parameter explicitly. So, PowerShell can not call string overload of Return method directly. You have to use some workaround to call it, for example, call it thru Reflection.Sample how can you create a simple expression tree ((a,b) => a*2+b) in PowerShell:
# First way: messing with [System.Linq.Expressions.Expression]
$a=[System.Linq.Expressions.Expression]::Parameter([int],'a')
$b=[System.Linq.Expressions.Expression]::Parameter([int],'b')
$2=[System.Linq.Expressions.Expression]::Constant(2)
$Body=[System.Linq.Expressions.Expression]::Add([System.Linq.Expressions.Expression]::Multiply($a,$2),$b)
$Sum=[System.Linq.Expressions.Expression]::Lambda([Func[int,int,int]],$Body,$a,$b)
$Sum
# Second way: using help of C#
Add-Type -TypeDefinition @'
using System;
using System.Linq.Expressions;
public static class MyExpression {
public static readonly Expression> Sum=(a,b) => a*2+b;
}
'@
[MyExpression]::Sum