Example #1
0
        public ICypherFluentQuery OneDeepAct()
        {
            var person = SampleDataFactory.GetWellKnownPerson(7);
            var q      = GetFluentQuery()
                         .MergeEntity(person);

            return(q);
        }
Example #2
0
        public ICypherFluentQuery CreateWithUnusualTypeAct()
        {
            var weapon = SampleDataFactory.GetWellKnownWeapon(1);

            var q = GetFluentQuery()
                    .CreateEntity(weapon, "w");

            return(q);
        }
Example #3
0
        public void MatchCypher()
        {
            var testPerson = SampleDataFactory.GetWellKnownPerson(7);

            // act
            var cypherKey = testPerson.ToCypherString <Person, CypherMatchAttribute>(new CypherExtensionContext(), "pkey");

            Console.WriteLine(cypherKey);

            // assert
            Assert.AreEqual("pkey:SecretAgent {id:{pkeyMatchKey}.id}", cypherKey);
        }
Example #4
0
        public void MatchEntity()
        {
            var person = SampleDataFactory.GetWellKnownPerson(7);
            var q      = GetFluentQuery()
                         .MatchEntity(person);
            var text = q.GetFormattedDebugText();

            Console.WriteLine(text);

            Assert.AreEqual(@"MATCH (person:SecretAgent {Id:{
  Id: 7
}.Id})", text);
        }
Example #5
0
        public ICypherFluentQuery CreateComplexAct()
        {
            var agent            = SampleDataFactory.GetWellKnownPerson(7);
            var homeRelationship = new HomeAddressRelationship(DateTimeOffset.Parse("2015-08-05 12:00+00:00"), "a", "ha");

            var q = GetFluentQuery()
                    .CreateEntity(agent, "a")
                    .CreateEntity(agent.HomeAddress, "ha")
                    .CreateEntity(agent.WorkAddress, "wa")
                    .CreateRelationship(homeRelationship)
                    .CreateRelationship(new WorkAddressRelationship("a", "wa"));

            return(q);
        }
Example #6
0
        public void CreateWithNullValuesSkipsTheNulls()
        {
            var agent = SampleDataFactory.GetWellKnownPerson(7);

            agent.HomeAddress.Suburb = null;

            var q = GetFluentQuery()
                    .CreateEntity(agent.HomeAddress);

            var text = q.GetFormattedDebugText();

            Assert.AreEqual(@"CREATE (address:Address {
  street: ""200 Isis Street""
})", text);
        }
Example #7
0
        public void OptionalMatchEntity()
        {
            var person = SampleDataFactory.GetWellKnownPerson(7);
            var q      = GetFluentQuery()
                         .MatchEntity(person)
                         .OptionalMatchEntity(person.HomeAddress, MatchOptions.Create("ha").WithNoProperties());
            var text = q.GetFormattedDebugText();

            Console.WriteLine(text);

            Assert.AreEqual(@"MATCH (person:SecretAgent {Id:{
  Id: 7
}.Id})
OPTIONAL MATCH (ha:Address)", text);
        }
Example #8
0
        public void OptionalMatchRelationship()
        {
            var person = SampleDataFactory.GetWellKnownPerson(7);
            var homeAddressRelationship = new HomeAddressRelationship();
            var q = GetFluentQuery()
                    .MatchEntity(person)
                    .OptionalMatchRelationship(homeAddressRelationship, MatchRelationshipOptions.Create().WithNoProperties());
            var text = q.GetFormattedDebugText();

            Console.WriteLine(text);

            Assert.AreEqual(@"MATCH (person:SecretAgent {Id:{
  Id: 7
}.Id})
OPTIONAL MATCH (person)-[personaddress:HOME_ADDRESS]->(address)", text);
        }
Example #9
0
        public ICypherFluentQuery TwoDeepAct()
        {
            //setup
            var testPerson = SampleDataFactory.GetWellKnownPerson(7);

            var homeAddressRelationship = new HomeAddressRelationship();

            // perhaps this would be modelled on the address node but serves to show how to attach relationship property
            homeAddressRelationship.DateEffective = DateTimeOffset.Parse("2011-01-10T08:00:00+03:00");

            //act
            var q = GetFluentQuery()
                    .MergeEntity(testPerson)
                    .MergeEntity(testPerson.HomeAddress, MergeOptions.ViaRelationship(homeAddressRelationship))
                    .MergeRelationship(homeAddressRelationship);

            return(q);
        }