public void SelectPropertyItem()
        {
            MemberAssignment[] assignments = new MemberAssignment[]
            {
                Expression.Property(sourceParam, "ListOfA").BindSelectedProperty <ObjectE, ObjectA, int>("ObjectB_Id", "Id", false)
            };

            ObjectE obj = listOfObjectD.Select(Expression.Lambda <Func <ObjectD, ObjectE> >(
                                                   Expression.MemberInit(Expression.New(typeof(ObjectE)), assignments)
                                                   , sourceParam).Compile()).FirstOrDefault();

            Assert.AreNotEqual(obj.ObjectB_Id, 0);
            Assert.AreEqual(obj.ObjectB_Id, listOfObjectD.SelectMany(d => d.ListOfA).Select(a => a.Id).FirstOrDefault());
        }
        public void SelectTestByProperty()
        {
            MemberAssignment[] assignments = new MemberAssignment[]
            {
                Expression.Property(sourceParam, "ListOfA").BindSelectedList <ObjectE, ObjectA, ObjectB>("ListOfB", ObjectB.FromObjectA)
            };

            ObjectE obj = listOfObjectD.Select(Expression.Lambda <Func <ObjectD, ObjectE> >(
                                                   Expression.MemberInit(Expression.New(typeof(ObjectE)), assignments)
                                                   , sourceParam).Compile()).FirstOrDefault();

            Assert.IsNotNull(obj.ListOfB);
            Assert.AreEqual(2, obj.ListOfB.Count());
        }
Example #3
0
        public void OrderByItemDescTest()
        {
            MemberAssignment[] assignments = new MemberAssignment[]
            {
                Expression.Property(sourceParam, "ListOfA").BindOrderedItem <ObjectE, ObjectA, int, ObjectB>("ObjectB", "Id", ObjectB.FromObjectA, true)
            };

            ObjectE obj = listOfObjectD.Select(Expression.Lambda <Func <ObjectD, ObjectE> >(
                                                   Expression.MemberInit(Expression.New(typeof(ObjectE)), assignments)
                                                   , sourceParam).Compile()).FirstOrDefault();

            Assert.IsNotNull(obj.ObjectB);
            Assert.AreEqual(9, obj.ObjectB.Id);
        }
Example #4
0
    private LogicGateEnum LogicGateEnumChange(ObjectE objectCondition, int objectConditionOption, ConditionE condition, int conditionOption, ActionE action, int actionOption, ObjectE objectAction, int objectActionOption)
    {
        LogicGateEnum logicGate = new LogicGateEnum();

        logicGate.objectCondition       = objectCondition;
        logicGate.objectConditionOption = objectConditionOption;
        logicGate.condition             = condition;
        logicGate.conditionOption       = conditionOption;
        logicGate.action             = action;
        logicGate.actionOption       = actionOption;
        logicGate.objectAction       = objectAction;
        logicGate.objectActionOption = objectActionOption;

        return(logicGate);
    }
Example #5
0
        public void OrderByListByNameTest()
        {
            MemberAssignment[] assignments = new MemberAssignment[]
            {
                sourceParam.BindOrderedList <ObjectE, ObjectA, int, ObjectB>("ListOfB", "ListOfA", "Id", ObjectB.FromObjectA)
            };

            ObjectE obj = listOfObjectD.Select(Expression.Lambda <Func <ObjectD, ObjectE> >(
                                                   Expression.MemberInit(Expression.New(typeof(ObjectE)), assignments)
                                                   , sourceParam).Compile()).FirstOrDefault();

            Assert.IsNotNull(obj.ListOfB);
            Assert.AreEqual(1, obj.ListOfB.FirstOrDefault().Id);
            Assert.AreEqual(9, obj.ListOfB.LastOrDefault().Id);
        }
        public void WhereSelectItemTestByName()
        {
            Func <Expression, Expression> predicateGenerator = param =>
                                                               Expression.Equal(Expression.Property(param, "Id"), Expression.Constant(1));

            MemberAssignment[] assignments = new MemberAssignment[]
            {
                sourceParam.BindFilteredItem <ObjectE, ObjectA, ObjectB>("ObjectB", "ListOfA", predicateGenerator, ObjectB.FromObjectA)
            };

            ObjectE obj = listOfObjectD.Select(Expression.Lambda <Func <ObjectD, ObjectE> >(
                                                   Expression.MemberInit(Expression.New(typeof(ObjectE)), assignments)
                                                   , sourceParam).Compile()).FirstOrDefault();

            Assert.IsNotNull(obj.ObjectB);
            Assert.AreEqual(1, obj.ObjectB.Id);
        }
Example #7
0
        public void FilterOrderByItemDescTest()
        {
            Func <Expression, Expression> predicateGenerator = param =>
                                                               Expression.LessThan(Expression.Property(param, "Id"), Expression.Constant(9));

            MemberAssignment[] assignments = new MemberAssignment[]
            {
                Expression.Property(sourceParam, "ListOfA").BindOrderedFilteredItem <ObjectE, ObjectA, int, ObjectB>("ObjectB", "Id", predicateGenerator, ObjectB.FromObjectA, true)
            };

            ObjectE obj = listOfObjectD.Select(Expression.Lambda <Func <ObjectD, ObjectE> >(
                                                   Expression.MemberInit(Expression.New(typeof(ObjectE)), assignments)
                                                   , sourceParam).Compile()).FirstOrDefault();

            Assert.IsNotNull(obj.ObjectB);
            Assert.AreEqual(7, obj.ObjectB.Id);
        }
        public void SelectPropertyList()
        {
            MemberAssignment[] assignments = new MemberAssignment[]
            {
                Expression.Property(sourceParam, "ListOfA").BindSelectedProperty <ObjectE, ObjectA, int>("ObjectB_Ids", "Id", true)
            };

            ObjectE obj = listOfObjectD.Select(Expression.Lambda <Func <ObjectD, ObjectE> >(
                                                   Expression.MemberInit(Expression.New(typeof(ObjectE)), assignments)
                                                   , sourceParam).Compile()).FirstOrDefault();

            Assert.IsTrue(obj.ObjectB_Ids.Count() > 0);

            foreach (int id in listOfObjectD.SelectMany(d => d.ListOfA).Select(a => a.Id))
            {
                Assert.IsTrue(obj.ObjectB_Ids.Contains(id));
            }
        }
        public void SelectFilteredProperty()
        {
            // Setup the bindings
            MemberAssignment[] assignments = new MemberAssignment[]
            {
                Expression.Property(sourceParam, nameof(ObjectD.ListOfA)).BindFilteredPropertyItem <ObjectE, ObjectA, int>(nameof(ObjectE.ObjectB_Id), (param) => {
                    return(Expression.Equal(
                               Expression.Property(param, nameof(ObjectA.Name)),
                               // Get the object with the matching name
                               Expression.Constant("Object A 1")
                               ));
                }, nameof(ObjectB.Id), false)
            };

            ObjectE obj = listOfObjectD.Select(Expression.Lambda <Func <ObjectD, ObjectE> >(
                                                   Expression.MemberInit(Expression.New(typeof(ObjectE)), assignments)
                                                   , sourceParam).Compile()).FirstOrDefault();

            Assert.IsNotNull(obj);
            Assert.AreEqual(1, obj.ObjectB_Id);
        }
 public virtual void MethodC(ObjectD arg1, ObjectE arg2)
 {
 }
Example #11
0
 public void MethodC(ObjectD arg1, ObjectE arg2)
 {
     Console.WriteLine("Bye {0} and {1}", arg1, arg2);
 }