Beispiel #1
0
        public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
        {
            if (binder.HasSingleUnnamedArgument())
            {
                return(UpdateByKeyFields(table.GetQualifiedName(), dataStrategy, args[0],
                                         MethodNameParser.ParseCriteriaNamesFromMethodName(binder.Name)));
            }

            var criteria           = MethodNameParser.ParseFromBinder(binder, args);
            var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), criteria);
            var data = binder.NamedArgumentsToDictionary(args)
                       .Where(kvp => !criteria.ContainsKey(kvp.Key))
                       .ToDictionary();

            return(dataStrategy.Update(table.GetQualifiedName(), data, criteriaExpression));
        }
Beispiel #2
0
        public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
        {
            object result;

            if (binder.HasSingleUnnamedArgument() || args.Length == 2 && args[1] is ErrorCallback)
            {
                result = UpsertByKeyFields(table.GetQualifiedName(), dataStrategy, args[0],
                                           MethodNameParser.ParseCriteriaNamesFromMethodName(binder.Name),
                                           !binder.IsResultDiscarded(),
                                           args.Length == 2 ? (ErrorCallback)args[1] : ((item, exception) => false));
            }
            else
            {
                var criteria           = MethodNameParser.ParseFromBinder(binder, args);
                var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(),
                                                                                         criteria);
                var data = binder.NamedArgumentsToDictionary(args);
                result = dataStrategy.Run.Upsert(table.GetQualifiedName(), data, criteriaExpression, !binder.IsResultDiscarded());
            }

            return(ResultHelper.TypeResult(result, table, dataStrategy));
        }