c# - Error with explicit conversion when using CollectAs<> -


right have simple problem, cannot life of me think of simple answer go it. code supposed return single 'person', collection of languages , countries.

return client.cypher             .match("(person:person)")             .where((person person) => person.email == username)             .optionalmatch("(person)-[:speaks]-(language:language)")             .optionalmatch("(person)-[:current_location]-(country:country)"             .return((person, language, country) => new profileobject             {                 person = person.as<person>(),                 language = language.collectas<language>(),                 country = country.collectas<country>()             }).results.tolist(); 

it looks right me, isn't, on build error, understand cannot solve.

cannot implicitly convert type 'system.collections.generic.ienumerable<neo4jclient.node<graph.country>>' 'graph.country'. explicit conversion exists (are missing cast?) 

the language class looks this

public class language {     public string name { get; set; } } 

and profileobject class looks this:

public class profileobject {     public person person { get; set; }     public language language { get; set; }     public country country { get; set; } } 

i stuck, please help.

collectas returns set of nodes.

you need change profileobject to:

public class profileobject {     public person person { get; set; }     public ienumerable<node<language>> language { get; set; }     public ienumerable<node<country>> country { get; set; } } 

in forthcoming update package, node<t> wrapper has been removed signature, be:

public class profileobject {     public person person { get; set; }     public ienumerable<language> language { get; set; }     public ienumerable<country> country { get; set; } } 

if want cleaner signature now, check out pre-release packages on nuget (https://www.nuget.org/packages/neo4jclient/1.1.0-tx00009).


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -