Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Neo4jClient节点/关系类约定_C#_Neo4j_Neo4jclient - Fatal编程技术网

C# Neo4jClient节点/关系类约定

C# Neo4jClient节点/关系类约定,c#,neo4j,neo4jclient,C#,Neo4j,Neo4jclient,使用Neo4jClient时,节点/关系类的属性/方法是否有标准命名约定 我将按照此链接创建我的关系类 public class Creates { private string _raw; private int _sourcePort; private string _image; private int _DestinationPort; private int _eventcode; private string _name; pr

使用Neo4jClient时,节点/关系类的属性/方法是否有标准命名约定

我将按照此链接创建我的关系类

public class Creates
{
    private string _raw;
    private int _sourcePort;
    private string _image;
    private int _DestinationPort;
    private int _eventcode;
    private string _name;
    private string _src_ip;
    private int _src_port;
    private string _dvc;
    private int _signature_ID;
    private string _dest_ip;
    private string _computer;
    private string _sourceType;
    private int _recordID;
    private int _processID;
    private DateTime _time;
    private int _dest_port;

    public string Raw { get { return _raw; } set { _raw = value; } }
    public int SourcePort { get { return _sourcePort; } set { _sourcePort = value; } }
    public string Image { get { return _image; } set { _image = value; } }
    public int DestinationPort { get { return _DestinationPort; } set { _DestinationPort = value; } }
    public int Eventcode { get { return _eventcode; } set { _eventcode = value; } }
    public string Name { get { return _name; } set { _name = value; } }
    public string Src_ip { get { return _src_ip; } set { _src_ip = value; } }
    public int Src_port { get { return _src_port; } set { _src_port = value; } }
    public string DVC { get { return _dvc; } set { _dvc = value; } }
    public int Signature_ID { get { return _signature_ID; } set { _signature_ID = value; } }
    public string Dest_ip { get { return _dest_ip; } set { _dest_ip = value; } }
    public string Computer { get { return _computer; } set { _computer = value; } }
    public string SourceType { get { return _sourceType; } set { _sourceType = value; } }
    public int RecordID { get { return _recordID; } set { _recordID = value; } }
    public int ProcessID { get { return _processID; } set { _processID = value; } }
    public DateTime Indextime { get { return _time; } set { _time = value; } }
    public int Dest_port { get { return _dest_port; } set { _dest_port = value; } }
}
然而,我的关系中有某些属性,尽管我的关系有它,但我无法获得任何价值。在调试代码时,我意识到在创建关系对象时,某些属性没有从关系中检索

这是我的人际关系课

public class Creates
{
    private string _raw;
    private int _sourcePort;
    private string _image;
    private int _DestinationPort;
    private int _eventcode;
    private string _name;
    private string _src_ip;
    private int _src_port;
    private string _dvc;
    private int _signature_ID;
    private string _dest_ip;
    private string _computer;
    private string _sourceType;
    private int _recordID;
    private int _processID;
    private DateTime _time;
    private int _dest_port;

    public string Raw { get { return _raw; } set { _raw = value; } }
    public int SourcePort { get { return _sourcePort; } set { _sourcePort = value; } }
    public string Image { get { return _image; } set { _image = value; } }
    public int DestinationPort { get { return _DestinationPort; } set { _DestinationPort = value; } }
    public int Eventcode { get { return _eventcode; } set { _eventcode = value; } }
    public string Name { get { return _name; } set { _name = value; } }
    public string Src_ip { get { return _src_ip; } set { _src_ip = value; } }
    public int Src_port { get { return _src_port; } set { _src_port = value; } }
    public string DVC { get { return _dvc; } set { _dvc = value; } }
    public int Signature_ID { get { return _signature_ID; } set { _signature_ID = value; } }
    public string Dest_ip { get { return _dest_ip; } set { _dest_ip = value; } }
    public string Computer { get { return _computer; } set { _computer = value; } }
    public string SourceType { get { return _sourceType; } set { _sourceType = value; } }
    public int RecordID { get { return _recordID; } set { _recordID = value; } }
    public int ProcessID { get { return _processID; } set { _processID = value; } }
    public DateTime Indextime { get { return _time; } set { _time = value; } }
    public int Dest_port { get { return _dest_port; } set { _dest_port = value; } }
}
这是另一门课

public class ProcessConnectedIP
{
    public Neo4jClient.RelationshipInstance<Pivot> bindto { get; set; }
    public Neo4jClient.Node<LogEvent> bindip { get; set; }
    public Neo4jClient.RelationshipInstance<Pivot> connectto { get; set; }
    public Neo4jClient.Node<LogEvent> connectip { get; set; }
}
这是我的neo4jclient查询,用于获取关系对象

public IEnumerable<ProcessConnectedIP> GetConnectedIPs(string nodeName)
    {
        try
        {
            var result =
                  this.client.Cypher.Match("(sourceNode:Process{name:{nameParam}})-[b:Bind_IP]->(bind:IP_Address)-[c:Connect_IP]->(connect:IP_Address)")
                .WithParam("nameParam", nodeName)
                .Where("b.dest_ip = c.dest_ip")
                .AndWhere("c.Image=~{imageParam}")
                .WithParam("imageParam", $".*" + nodeName + ".*")
                .Return((b, bind, c, connect) => new ProcessConnectedIP
                {
                    bindto = b.As<RelationshipInstance<Creates>>(),
                    bindip = bind.As<Node<LogEvent>>(),
                    connectto = c.As<RelationshipInstance<Creates>>(),
                    connectip = connect.As<Node<LogEvent>>()
                })
                .Results;
            return result;
        }catch(Exception ex)
        {
            Console.WriteLine("GetConnectedIPs: Error Msg: " + ex.Message);
            return null;
        }
    }
这是读取结果的方法

public void MyMethod(string name)
    {
        IEnumerable<ProcessConnectedIP> result = clientDAL.GetConnectedIPs(name);
        if(result != null)
        {
            var results = result.ToList();
            Console.WriteLine(results.Count());
            foreach (ProcessConnectedIP item in results)
            {
                Console.WriteLine(item.Data.Src_ip);
                Console.WriteLine(item.bindto.StartNodeReference.Id);
                Console.WriteLine(item.bindto.EndNodeReference.Id);
                Console.WriteLine(item.connectto.StartNodeReference.Id);
                Console.WriteLine(item.connectto.EndNodeReference.Id);

                Node<LogEvent> ans = item.bindip;
                LogEvent log = ans.Data;
                Console.WriteLine(log.Name);

                Node<LogEvent> ans1 = item.connectip;
                LogEvent log1 = ans1.Data;
                Console.WriteLine(log1.Name);
            }
        }
    }
不知何故,我只能用src_ip/src_port/dest_ip/dest_port值填充关系对象。其余的都是空的

有什么可能的原因吗?我在属性名称上使用了大写/小写,但似乎不起作用

这是我正在处理的图表的一部分

这是关系属性示例:

_原始:一些XML数据源端口:49767Image:C:\Windows\explorer.exeDestinationPort:443EventCode:3Name:Bind IPsrc_ip:172.10.10.104dvc:计算机名称RC_端口: 49767签名id:3dest\u ip:172.10.10.11计算机: COMPUTRE-NAME\u源类型: XmlWinEventLog:Microsoft Windows Sysmon/OperationalRecordID: 13405621进程ID:7184时间:2017-08-28T15:15:39+08:00目的港:443


我不完全确定Creates类是如何填充的,尤其是那些字段,因为您的Src_-port属性与您提供的示例中的Src_-port不匹配

我认为最好还是回到一个超级简单的版本。Neo4jClient将您的属性映射到关系中的属性,只要它们具有相同的名称且区分大小写

因此,从一个新的Creates类开始,使用auto properties-它将使您的生活更加轻松

public class Creates
{
    public string Computer { get; set; }
}

用它运行查询并查看是否得到结果,然后继续添加与希望返回int、string等的名称和类型匹配的属性。似乎我必须以小写形式提供neo4j节点/关系属性名称,并且在属性名称的开头不带特殊字符,以使上述代码正常工作


这张图不是我一开始创建的,因此我必须按照给定的内容进行处理。我必须让创建图的开发人员使用小写字母创建节点,以使上述功能正常工作。

嗨,克里斯,我也发表了自己的观察,如果neo4j节点/关系属性名称是小写的,那么我上面的代码就可以正常工作。这是真的吗?在创建节点和命名其标签/属性等方面的关系时,是否有严格的规则要遵循?不,不是这样的,属性的情况可以是任何情况-如果是其他人创建的,那么它们可能对所有内容都使用小写,您可以使用[JsonPropertycomputer]装饰您的属性例如,要将其视为小写,上述语句不正确。听从克里斯的建议