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: