Beispiel #1
0
        public MassUpdater(string table, Expression <Func <T, Object> > idGetterExpr, params Expression <Func <T, Object> >[] getterExprs)
        {
            this.table = table;

            chosenPropsOrFields = new Dictionary <string, GetValue>(getterExprs.Length);
            var tempGetters = CachedTypeData.FetchGettersOf <T>();

            // Only add the ones we want
            foreach (var getterExpr in getterExprs)
            {
                string propOrFieldName = ExpressionTreeHelper.GetPropOrFieldNameFromLambdaExpr <T>(getterExpr);
                chosenPropsOrFields.Add(propOrFieldName, tempGetters[propOrFieldName]);
            }
            // Add the id getter
            this.idColumn = ExpressionTreeHelper.GetPropOrFieldNameFromLambdaExpr <T>(idGetterExpr);
            this.idGetter = chosenPropsOrFields[idColumn];

            this.regs = new List <T>(50);
        }
Beispiel #2
0
        public void Update <T>(string table, Object obj, Expression <Func <T, Object> > idGetterExpr, params Expression <Func <T, Object> >[] getterExprs)
        {
            ObjectAndColumns reg = new ObjectAndColumns {
                table = table,
                chosenPropsOrFields = new Dictionary <string, GetValue>(getterExprs.Length),
                idColumn            = ExpressionTreeHelper.GetPropOrFieldNameFromLambdaExpr <T>(idGetterExpr),
                obj = obj
            };

            var tempGetters = CachedTypeData.FetchGettersOf <T>();

            // Only add the ones we want
            foreach (var getterExpr in getterExprs)
            {
                string propOrFieldName = ExpressionTreeHelper.GetPropOrFieldNameFromLambdaExpr <T>(getterExpr);
                reg.chosenPropsOrFields.Add(propOrFieldName, tempGetters[propOrFieldName]);
            }
            // Add the id getter
            reg.idGetter = tempGetters[reg.idColumn];

            regs.Add(reg);
        }