Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-02-2019 09:32 AM
I'm 100% new to Neo4j, and a bit of a neophyte in coding as well. I have a project that I want to test the usefulness of a graph database for and have downloaded the Neo4j Community edition. I have been running through some of the tutorials, and I came into an issue with the HelloWorld code used in the .NET example. Particularly this line
return result.Single()[0].As();
Visual Studio 2017 does not understand what type it is supposed to be cast to. After almost an hour of researching (Again I am new to programming), I finally found that the following change worked.
return result.Single()[0].As<string>();
or even
return result.Single()[0];
What was the code supposed to be doing? Or is it supposed to be casting to a specific type?
Thank you,
Mike Fontaine
Solved! Go to Solution.
09-16-2019 09:28 AM
Wow, totally missed this - yes, it should have been return result.Single()[0].As<string>();
The As<>
bit is the type you're pulling from the database, so, in the example, because you're doing:
"RETURN a.message + ', from node ' + id(a)",
You are returning a string
.
If you did:
"RETURN id(a)"
instead, you would do:
return result.Single()[0].As<int>()
though if you did <string>
that would work as well, as .NET can cast the int into a string
as well as an int
.
Does that make sense?
09-16-2019 09:28 AM
Wow, totally missed this - yes, it should have been return result.Single()[0].As<string>();
The As<>
bit is the type you're pulling from the database, so, in the example, because you're doing:
"RETURN a.message + ', from node ' + id(a)",
You are returning a string
.
If you did:
"RETURN id(a)"
instead, you would do:
return result.Single()[0].As<int>()
though if you did <string>
that would work as well, as .NET can cast the int into a string
as well as an int
.
Does that make sense?
All the sessions of the conference are now available online