Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.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# NET客户端执行字符串密码查询_C#_.net_Neo4j_Cypher_Neo4jclient - Fatal编程技术网

C# NET客户端执行字符串密码查询

C# NET客户端执行字符串密码查询,c#,.net,neo4j,cypher,neo4jclient,C#,.net,Neo4j,Cypher,Neo4jclient,是否可以使用Neo4j.NET客户端或任何其他模块将密码查询作为普通的旧字符串执行 例如,如果我想将一些节点添加到我的图形数据库中,并且已经组装好了语句,是否有执行字符串的方法: CREATE (n:Edit {name:"L-1154LX"}); 我希望批量处理已创建的CREATE CYPHER查询列表。正式记录在 但是,这将不利于性能,并且对安全性有风险 这对性能不利,因为它必须重新解析每个查询。您应该使用参数,就像下面的示例中那样,查询文本保持一致,只是参数不同,因此不会在每次调用时产生

是否可以使用Neo4j.NET客户端或任何其他模块将密码查询作为普通的旧字符串执行

例如,如果我想将一些节点添加到我的图形数据库中,并且已经组装好了语句,是否有执行字符串的方法:

CREATE (n:Edit {name:"L-1154LX"});
我希望批量处理已创建的CREATE CYPHER查询列表。

正式记录在

但是,这将不利于性能,并且对安全性有风险

这对性能不利,因为它必须重新解析每个查询。您应该使用参数,就像下面的示例中那样,查询文本保持一致,只是参数不同,因此不会在每次调用时产生查询编译成本

这对安全性来说是有风险的,因为您很容易将编码弄错,并将自己暴露在注入风险中


所以,请不要运行手动查询,除非您真正了解自己在做什么。它们是故意隐藏的。

我正在编写一个.NET应用程序,可以从Excel电子表格中提取节点和关系,以便动态生成并加载到neo4j中(请参见下面的翻译/管理对象模型)

当我通过neo4jclient将它们加载到neo4j中时,我不知道我的节点在运行时是什么样子;它们可以具有任意数量的属性,并且可以具有任意名称和值。在这里的示例中,我应该有本地类来引用属性名和值;但这是行不通的。我错过了一个技巧吗?参数化查询?(即使这些示例也需要一个本地的硬编码类)

公共类节点
{
公共字符串NodeType=“”;
公共列表属性;
公共关系;
公共关系;
公共节点(字符串节点类型)
{
节点类型=节点类型;
属性=新列表();
ParentRelationships=新列表();
ChildRelationships=新列表();
}
公共void AddAttribute(属性)
{
//我们不允许使用空属性
如果(attribute.GetValue()!=“”)
this.Attributes.Add(属性);
}
公共字符串GetIdentifier()
{
foreach(属性中的属性a)
{
如果(识别器)
返回a.GetValue();
}
返回null;
}
公共关系(关系公关)
{
父母关系。添加(pr);
}
公共关系(关系cr)
{
儿童关系。添加(cr);
}
公共类属性
{
私有字符串名称;
私有字符串值;
公共图书馆识别器;
公共属性(字符串名称、字符串值、布尔isIdentifier)
{
集合名(名称);
设置值(值);
IsIdentifier=IsIdentifier;
}
公共void集合名(字符串名)
{
Name=Name.Trim();
}
公共void设置值(字符串值)
{
Value=Value.Trim();
}
公共字符串GetName()
{
返回名称;
}
公共字符串GetValue()
{
返回值;
}
}

谢谢!我在代码中实现此功能时遇到问题。我假设“查询”是原始字符串密码查询,但这只是标准客户端对象的一个方法吗?我使用的是.NET客户端。我真的警告您不要这样做。有更好、更安全、更快的方法来做您想做的事情。我链接的文档提供了三行代码,您可以直接复制和粘贴。请注意,这些方法e显式接口实现,因此要求您首先强制转换到IRawGraphClient。但是,我仍然不鼓励您这样做。真的。真的。改为遵循以下代码:
 public class Node
        {
            public string NodeType = "";
            public List<Attribute> Attributes;
            public List<Relationship> ParentRelationships;
            public List<Relationship> ChildRelationships;
            public Node(string nodeType)
            {
                NodeType = nodeType;
                Attributes = new List<Attribute>();
                ParentRelationships = new List<Relationship>();
                ChildRelationships = new List<Relationship>();
            }

            public void AddAttribute(Attribute attribute)
            {
                //We are not allowing empty attributes
                if(attribute.GetValue() != "")
                    this.Attributes.Add(attribute);
            }

            public string GetIdentifier()
            {
                foreach (Attribute a in Attributes)
                {
                    if (a.IsIdentifier)
                        return a.GetValue();
                }
                return null;
            }

            public void AddParentRelationship(Relationship pr)
            {
                ParentRelationships.Add(pr);
            }

            public void AddChildRelationship(Relationship cr)
            {
                ChildRelationships.Add(cr);
            }

  public class Attribute
        {
            private string Name;
            private string Value;
            public bool IsIdentifier;

            public Attribute(string name, string value, bool isIdentifier)
            {
                SetName(name);
                SetValue(value);
                IsIdentifier = isIdentifier;
            }

            public void SetName(string name)
            {
                Name = name.Trim();
            }
            public void SetValue(string value)
            {
                Value = value.Trim();
            }
            public string GetName()
            {
                return Name;
            }
            public string GetValue()
            {
                return Value;
            }

        }