public CypherFluentQueryAdvanced(IGraphClient client, QueryWriter queryWriter, bool isWrite, bool includeQueryStats)
 {
     this.client            = client;
     this.queryWriter       = queryWriter;
     this.isWrite           = isWrite;
     this.includeQueryStats = includeQueryStats;
 }
Ejemplo n.º 2
0
        public void EmptyQueryForNoClauses()
        {
            var writer = new QueryWriter();

            var query = writer.ToCypherQuery();
            Assert.AreEqual("", query.QueryText);
            Assert.AreEqual(0, query.QueryParameters.Count);
        }
Ejemplo n.º 3
0
 internal CypherFluentQuery(IGraphClient client, QueryWriter queryWriter, bool isWrite = true)
 {
     Client              = client as IRawGraphClient ?? throw new ArgumentException("The supplied graph client also needs to implement IRawGraphClient", nameof(client));
     QueryWriter         = queryWriter;
     CamelCaseProperties = Client.JsonContractResolver is CamelCasePropertyNamesContractResolver;
     Advanced            = new CypherFluentQueryAdvanced(Client, QueryWriter, isWrite);
     IsWrite             = isWrite;
 }
Ejemplo n.º 4
0
        public CypherFluentQuery(IGraphClient client)
        {
            if (!(client is IRawGraphClient))
            {
                throw new ArgumentException("The supplied graph client also needs to implement IRawGraphClient", "client");
            }

            Client      = (IRawGraphClient)client;
            QueryWriter = new QueryWriter();
        }
Ejemplo n.º 5
0
        protected CypherFluentQuery(IGraphClient client, QueryWriter queryWriter)
        {
            if (!(client is IRawGraphClient))
            {
                throw new ArgumentException("The supplied graph client also needs to implement IRawGraphClient", "client");
            }

            Client      = (IRawGraphClient)client;
            QueryWriter = queryWriter;
        }
Ejemplo n.º 6
0
        public void AppendClause()
        {
            var writer = new QueryWriter();

            writer.AppendClause("foo");

            var query = writer.ToCypherQuery();
            Assert.AreEqual("foo", query.QueryText);
            Assert.AreEqual(0, query.QueryParameters.Count);
        }
Ejemplo n.º 7
0
        protected CypherFluentQuery(IGraphClient client, QueryWriter queryWriter)
        {
            if (!(client is IRawGraphClient))
            {
                throw new ArgumentException("The supplied graph client also needs to implement IRawGraphClient", "client");
            }

            Client              = (IRawGraphClient)client;
            QueryWriter         = queryWriter;
            camelCaseProperties = Client.JsonContractResolver is CamelCasePropertyNamesContractResolver;
        }
Ejemplo n.º 8
0
        public void AppendClauseWithParameter()
        {
            var writer = new QueryWriter();

            writer.AppendClause("foo {0}", "bar");

            var query = writer.ToCypherQuery();
            Assert.AreEqual("foo {p0}", query.QueryText);
            Assert.AreEqual(1, query.QueryParameters.Count);
            Assert.AreEqual("bar", query.QueryParameters["p0"]);
        }
Ejemplo n.º 9
0
        public void AppendClauseWithMultipleParameters()
        {
            var writer = new QueryWriter();

            writer.AppendClause("foo {0} bar {1}", "baz", "qak");

            var query = writer.ToCypherQuery();
            Assert.AreEqual("foo {p0} bar {p1}", query.QueryText);
            Assert.AreEqual(2, query.QueryParameters.Count);
            Assert.AreEqual("baz", query.QueryParameters["p0"]);
            Assert.AreEqual("qak", query.QueryParameters["p1"]);
        }
Ejemplo n.º 10
0
        public void ToCypherQueryShouldNotIncrementParamCountsWhenGeneratedTwice()
        {
            var writer = new QueryWriter();

            writer.AppendClause("foo {0}", "bar");

            var query1 = writer.ToCypherQuery();
            Assert.AreEqual("foo {p0}", query1.QueryText);
            Assert.AreEqual(1, query1.QueryParameters.Count);
            Assert.AreEqual("bar", query1.QueryParameters["p0"]);

            var query2 = writer.ToCypherQuery();
            Assert.AreEqual("foo {p0}", query2.QueryText);
            Assert.AreEqual(1, query2.QueryParameters.Count);
            Assert.AreEqual("bar", query2.QueryParameters["p0"]);
        }
Ejemplo n.º 11
0
        public void AppendMultipleClausesWithMultipleParameters()
        {
            var writer = new QueryWriter();

            writer.AppendClause("foo {0} bar {1}", "baz", "qak");
            writer.AppendClause("{0} qoo {1} zoo", "abc", "xyz");

            var query = writer.ToCypherQuery();
            const string expectedText = @"foo {p0} bar {p1}
            {p2} qoo {p3} zoo";
            Assert.AreEqual(expectedText, query.QueryText);
            Assert.AreEqual(4, query.QueryParameters.Count);
            Assert.AreEqual("baz", query.QueryParameters["p0"]);
            Assert.AreEqual("qak", query.QueryParameters["p1"]);
            Assert.AreEqual("abc", query.QueryParameters["p2"]);
            Assert.AreEqual("xyz", query.QueryParameters["p3"]);
        }
Ejemplo n.º 12
0
        public void ToCypherQueryShouldNotLeakNewParamsIntoPreviouslyBuiltQuery()
        {
            var writer = new QueryWriter();

            writer.AppendClause("foo {0}", "bar");
            var query1 = writer.ToCypherQuery();

            writer.AppendClause("baz {0}", "qak");
            var query2 = writer.ToCypherQuery();

            Assert.AreEqual("foo {p0}", query1.QueryText);
            Assert.AreEqual(1, query1.QueryParameters.Count);
            Assert.AreEqual("bar", query1.QueryParameters["p0"]);

            Assert.AreEqual("foo {p0}\r\nbaz {p1}", query2.QueryText);
            Assert.AreEqual(2, query2.QueryParameters.Count);
            Assert.AreEqual("bar", query2.QueryParameters["p0"]);
            Assert.AreEqual("qak", query2.QueryParameters["p1"]);
        }
 public CypherFluentQueryAdvanced(IGraphClient client, QueryWriter queryWriter)
 {
     this.client      = client;
     this.queryWriter = queryWriter;
 }
 public CypherFluentQuery(IGraphClient client, QueryWriter writer)
     : base(client, writer)
 {
 }
 public CypherFluentQueryAdvanced(IGraphClient client, QueryWriter queryWriter, bool isWrite = true)
 {
     this.client      = client;
     this.queryWriter = queryWriter;
     this.isWrite     = isWrite;
 }
Ejemplo n.º 16
0
 public CypherFluentQuery(IGraphClient client, QueryWriter writer, bool isWrite = true)
     : base(client, writer, isWrite)
 {
 }
 public CypherFluentQuery(IGraphClient client, QueryWriter writer, bool isWrite = true, bool includeQueryStats = false)
     : base(client, writer, isWrite, includeQueryStats)
 {
 }
Ejemplo n.º 18
0
        public void AppendMultipleClausesWithMultipleParameters()
        {
            var writer = new QueryWriter();

            writer.AppendClause("foo {0} bar {1}", "baz", "qak");
            writer.AppendClause("{0} qoo {1} zoo", "abc", "xyz");

            var query = writer.ToCypherQuery();
            string expectedText = string.Format("foo {{p0}} bar {{p1}}{0}{{p2}} qoo {{p3}} zoo", Environment.NewLine);
            Assert.AreEqual(expectedText, query.QueryText);
            Assert.AreEqual(4, query.QueryParameters.Count);
            Assert.AreEqual("baz", query.QueryParameters["p0"]);
            Assert.AreEqual("qak", query.QueryParameters["p1"]);
            Assert.AreEqual("abc", query.QueryParameters["p2"]);
            Assert.AreEqual("xyz", query.QueryParameters["p3"]);
        }