Return Error

I follow this little post: https://github.com/Readify/Neo4jClient/wiki/cypher , but I am doing this from Powershell. so i still

[System.Reflection.Assembly]::LoadFrom("C:\...\Newtonsoft.Json.6.0.3\lib\net40\NewtonSoft.Json.dll")
[System.Reflection.Assembly]::LoadFrom("C:\...\Neo4jClient.1.0.0.662\lib\net40\Neo4jClient.dll")

$neo = new-object Neo4jClient.GraphClient(new-object Uri("http://localhost:7474/db/data"))
$q=$neo.Cypher.Match("n").Return({param($m) $m});

with which I would like to get all the nodes in the database. the method is Return()shown in the example to require lambda to be expressed as a parameter that would be a block of code in Powershell, however I get the following error:

Unable to find overload for "Return" and number of arguments: "1". To line: 1 char: 1 + $ q = $ neo.Cypher.Match ("n"). Return ({param ($ m) $ m}); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ CategoryInfo: NotSpecified: (:) [], MethodException + FullyQualifiedErrorId: MethodCountCouldNotFindBest

where am i wrong

* Update i *

, @PetSerAl , , . (#), powershell.

public class User
{
    public long Id { get; set; }
    public string Name { get; set; }
    public int Age { get; set; }
    public string Email { get; set; }
}

Add-Type -TypeDefinition "public class Project { public string Code; public string Name; public string Parent; public string Lifespan; }"

Cypher

MATCH (user:User)
RETURN user

#

graphClient.Cypher
    .Match("(user:User)")
    .Return(user => user.As<User>())
    .Results

cypher

MATCH (n:Project)
RETURN n

... , , powershell:

$exp = [System.Linq.Expressions.Expression]
$p = $exp::Constant("Project")
$fn = $exp::TypeAs($p, (new-object Project).GetType())
$return = $exp::Lambda([Func[Project]], $fn, $p)
$neo.Cypher.Match("n").Return($return)

"" "1": " (: n = > new MyResultType {Foo = n.Bar}), ( : n = > new {Foo = n.Bar}), (: n = > n.Count()) (: n = > n.As(). Bar). (: n = > {var a = n + 1; return a; }) (: n = > new Foo ()). F #, . : " : 1 char: 1 + $neo.Cypher.Match( "n" ). ($ return) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + CategoryInfo: NotSpecified: (:) [], MethodInvocationException     + FullyQualifiedErrorId: ArgumentException

. , , . n => n.Count() .

?

* II *

, neo4j powershell, @PetSerAl , , . :

$neopath = "C:\[...]\Neo4jClient.dll"
Add-Type -ReferencedAssemblies $neopath -TypeDefinition @"
    using System;
    using System.Linq.Expressions;
    using Neo4jClient.Cypher;
    public class Project {
        public string Code;
        public string Name;
        public string Parent;
        public string Lifespan;
    };
    public static class NeoExp {
        public static readonly Expression<Func<Neo4jClient.Cypher.ICypherResultItem,Project>> GetProject = (n) => n.As<Project>();
}
"@

:

$neo.Cypher.Match("n:Project").Return([NeoExp]::GetProject)

, , ! , :

Results ResultsAsync Query                         Client 
------- ------------ -----                         ------                                                                      
                     Neo4jClient.Cypher.CypherQ... Neo4jClient.GraphClient

, ... ?

* III *

, , . @PetSerAl. :

$neo.Cypher.Match("n:Project").Return([NeoExp]::GetProject).get_Results()

:

"get_Results" "0": " . Connect.

, :

$neo.Connect()

:

$neo.Cypher.Match("(n:Project)").Return([NeoExp]::GetProject)

27 , , .Results... . , , , n.As<Project>(), , , , . ?

* IV *

, . Project , :

    public class Project {
        public string Code { get; set; }
        public string Name { get; set; }
        public string Parent { get; set; }
        public string Lifespan { get; set; }
    };

. . !!!

@PetSelAl:

+4
4

@PetSerAl, , .

, , Powershell , neo4jClient library .Return . , Powershell .

:

wiki Neo4jClient, , . @PetSerAl

0

Return:

  • , . PowerShell ScriptBlock. , string.
  • string PowerShell , PowerShell . , PowerShell string Return. , , Reflection.

, ((a,b) => a*2+b) 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<Func<int,int,int>> Sum=(a,b) => a*2+b;
    }
'@
[MyExpression]::Sum
+2

, , , , , # PowerShell Add-Type. , , PowerShell, , , # .

:

$source = @"
public class BasicTest
{
  public static int Add(int a, int b)
  {
    return (a + b);
  }
  public int Multiply(int a, int b)
  {
    return (a * b);
  }
}
"@
Add-Type -TypeDefinition $source
[BasicTest]::Add(4, 3)
$basicTestObject = New-Object BasicTest
$basicTestObject.Multiply(5, 2)
+1

, , , . Neo4jClient, . , Return , . - :

$neo = new-object Neo4jClient.GraphClient(new-object Uri("http://localhost:7474/db/data"))
$neo.Cypher.Match = "n"
$neo.Cypher.Return = {param($m) $m}
$q = $neo.Cypher.Results()

, Match, , , (, ), $q. , , :

SELECT * FROM Uri("http://localhost:7474/db/data")) WHERE "n"

Match, , , / , . , $neo.Cypher | Get-Member, , , .

: , . , PowerShell .Net. - , . 37 , 750 . ICypherResultItem, (string identity). Return("*")?

0

All Articles