代码之家  ›  专栏  ›  技术社区  ›  cheenu

使用neo4jClient从Cypher查询返回财产

  •  1
  • cheenu  · 技术社区  · 11 年前

    我的目标是从两个相关节点返回两个财产。

    我希望从DataSpaceName/DataSpace属性匹配的两个节点返回DataSpace中的DataSpaceName和Entity中的EntityName。

    public class DataSpace
    {   
     public string DataSpaceName { get; set;}        
     public string DataSpaceDescription { get; set;}
     public string ConnectionString { get; set;}
    }
    
    public class Entity
    {
     public string DataConnector { get; set;}
     public string EntityName  { get; set;}
     public string EntityType  { get; set;}
     public string DataSpace{get; set;} 
    }
    
    var query = 
        client
        .Cypher
        .Match("(DataSpace:DataSpace), (Entity:Entity)")
        .Where("Entity.DataSpace = DataSpace.DataSpaceName")
        .Return ((DataSpace,Entity) => new { 
                    DSName = Return.As<string>("DataSpace.DataSpaceName"),
                    EName=Return.As<string>("Entity.EntityName")
                    });
    

    这会引发错误:

    Compiler Error Message: CS0103: The name 'Return' does not exist in the current context
    

    如果我使用Node(比如DataSpace.As())而不是Return,我会得到整个DataSpace Node。

    有人能解释一下我在这件事上犯的错误吗。

    1 回复  |  直到 11 年前
        1
  •  2
  •   Tatham Oddie    11 年前

    看起来您只导入了 Neo4jClient 命名空间。您需要导入 Neo4jClient.Cypher 如果您想使用 Return

    ReSharper也会建议你这样做。