public void Visit()
        {
            System.Linq.Expressions.Expression<Func<int, int, bool>> largeSumTestExpression = (num1, num2) => (num1 + num2) > 1000;
            Func<int, int, bool> largeSumTest = largeSumTestExpression.Compile();

            TestDataObject obj = new TestDataObjectImpl() { StringProperty = "test", TestField = "test2" };
            TestObj obj2 = new TestObj() { TestField = "Test2" };
            TestQuery<TestDataObject> ctx = new TestQuery<TestDataObject>();
            var list = from o in ctx
                       where o.IntProperty == 1
                           && o.IntProperty != 2
                           && o.IntProperty > 3
                           && o.IntProperty == obj.ID
                           && o.StringProperty == obj2.TestField
                           && o.StringProperty == obj.StringProperty
                           && o.StringProperty.StartsWith(obj2.TestField)
                           && (o.StringProperty.StartsWith("test") || o.StringProperty == "test")
                           && (o.StringProperty is string)
                           && !o.BoolProperty
                           && o.BoolProperty ? false : true
                           && o.StringProperty == new DateTime().ToShortDateString()
                           && new int[] { 1, obj.IntProperty }.Length == 2
                           && (obj.IntProperty + o.StringProperty.Length) == 4
                           && largeSumTest(o.IntProperty, o.IntProperty)
                       select new
                       {
                           o.IntProperty,
                           o.BoolProperty,
                           Test = o.IntProperty * 2,
                           Test2 = MethodCallTest(o.StringProperty.Length * 2),
                           TestList = new int[] { o.IntProperty, o.ID, o.StringProperty.Length },
                           TestObj = new { o.BoolProperty, o.ID },
                           Date = new DateTime(1000),
                           Test3 = obj.StringProperty,
                           Test4 = new TestDataObjectImpl() { StringProperty = o.StringProperty, ID = MethodCallTest(o.IntProperty) },
                           Test5 = new List<TestDataObject> {
                                new TestDataObjectImpl() { StringProperty = obj.StringProperty, ID = o.IntProperty },
                                new TestDataObjectImpl() { StringProperty = o.StringProperty, ID = MethodCallTest(o.IntProperty) }
                           },
                           Test6 = MethodCallTest(2),
                           Test7 = new List<TestDataObject>() { new TestDataObjectImpl(), obj }.Max(x => x.ID),
                       };

            // The TestProvider does not implement Projections
            // But in that case we just whant to test the visitor
            var result = list.GetEnumerator();
            Assert.That(result, Is.Null);
        }
Example #2
0
            private SerializableExpression CreateExpression()
            {
                // Cannot use another ZetboxObject because in this tests we do not do any type transformations
                //TestDataObject obj = new TestDataObjectImpl();
                TestObj obj2 = new TestObj();
                TestQuery <TestDataObject> ctx = new TestQuery <TestDataObject>();
                var list = from o in ctx
                           where o.IntProperty == 1 &&
                           o.IntProperty != 2 &&
                           o.IntProperty > 3
                           //&& o.IntProperty == obj.ID
                           && o.StringProperty == obj2.TestField
                           //&& o.StringProperty == obj.StringProperty
                           && o.StringProperty.StartsWith(obj2.TestField) &&
                           (o.StringProperty.StartsWith("test") || o.StringProperty == "test") &&
                           !o.BoolProperty
                           select new
                {
                    o.IntProperty,
                    o.BoolProperty
                };

                return(Zetbox.API.SerializableExpression.FromExpression(list.Expression, iftFactory));
            }
Example #3
0
        public void Visit()
        {
            System.Linq.Expressions.Expression <Func <int, int, bool> > largeSumTestExpression = (num1, num2) => (num1 + num2) > 1000;
            Func <int, int, bool> largeSumTest = largeSumTestExpression.Compile();

            TestDataObject obj = new TestDataObjectImpl()
            {
                StringProperty = "test", TestField = "test2"
            };
            TestObj obj2 = new TestObj()
            {
                TestField = "Test2"
            };
            TestQuery <TestDataObject> ctx = new TestQuery <TestDataObject>();
            var list = from o in ctx
                       where o.IntProperty == 1 &&
                       o.IntProperty != 2 &&
                       o.IntProperty > 3 &&
                       o.IntProperty == obj.ID &&
                       o.StringProperty == obj2.TestField &&
                       o.StringProperty == obj.StringProperty &&
                       o.StringProperty.StartsWith(obj2.TestField) &&
                       (o.StringProperty.StartsWith("test") || o.StringProperty == "test") &&
                       (o.StringProperty is string) &&
                       !o.BoolProperty &&
                       o.BoolProperty ? false : true &&
                       o.StringProperty == new DateTime().ToShortDateString() &&
                       new int[] { 1, obj.IntProperty }.Length == 2 &&
            (obj.IntProperty + o.StringProperty.Length) == 4 &&
            largeSumTest(o.IntProperty, o.IntProperty)
            select new
            {
                o.IntProperty,
                o.BoolProperty,
                Test     = o.IntProperty * 2,
                Test2    = MethodCallTest(o.StringProperty.Length * 2),
                TestList = new int[] { o.IntProperty, o.ID, o.StringProperty.Length },
                TestObj  = new { o.BoolProperty, o.ID },
                Date     = new DateTime(1000),
                Test3    = obj.StringProperty,
                Test4    = new TestDataObjectImpl()
                {
                    StringProperty = o.StringProperty, ID = MethodCallTest(o.IntProperty)
                },
                Test5 = new List <TestDataObject> {
                    new TestDataObjectImpl()
                    {
                        StringProperty = obj.StringProperty, ID = o.IntProperty
                    },
                    new TestDataObjectImpl()
                    {
                        StringProperty = o.StringProperty, ID = MethodCallTest(o.IntProperty)
                    }
                },
                Test6 = MethodCallTest(2),
                Test7 = new List <TestDataObject>()
                {
                    new TestDataObjectImpl(), obj
                }.Max(x => x.ID),
            };

            // The TestProvider does not implement Projections
            // But in that case we just whant to test the visitor
            var result = list.GetEnumerator();

            Assert.That(result, Is.Null);
        }
Example #4
0
 private SerializableExpression CreateExpression()
 {
     // Cannot use another ZetboxObject because in this tests we do not do any type transformations
     //TestDataObject obj = new TestDataObjectImpl();
     TestObj obj2 = new TestObj();
     TestQuery<TestDataObject> ctx = new TestQuery<TestDataObject>();
     var list = from o in ctx
                where o.IntProperty == 1
                && o.IntProperty != 2
                && o.IntProperty > 3
                    //&& o.IntProperty == obj.ID
                && o.StringProperty == obj2.TestField
                    //&& o.StringProperty == obj.StringProperty
                && o.StringProperty.StartsWith(obj2.TestField)
                && (o.StringProperty.StartsWith("test") || o.StringProperty == "test")
                && !o.BoolProperty
                select new
                {
                    o.IntProperty,
                    o.BoolProperty
                };
     return Zetbox.API.SerializableExpression.FromExpression(list.Expression, iftFactory);
 }