public static object Update(UpdateHandlerConfig handlerConfig, object complexData, IDictionary <string, object> queryParams = null)
        {
            IUpdateHandler updateHandler = UpdateHandlerFactory.GetUpdateHandler(handlerConfig.QueryType);
            var            context       = new UpdateContext
            {
                HandlerConfig = handlerConfig,
                Configs       = handlerConfig.Configs,
                Params        = queryParams,
                ComplexData   = complexData
            };

            ParamConvertUtil.DoConvert(context);
            var result = updateHandler.Update(context);

            if (context.Conns != null && context.Conns.Any())
            {
                context.Submit();
            }

            return(result);
        }
Exemple #2
0
        public static object Query(HandlerConfig handlerConfig, object complexData, IDictionary <string, object> queryParams = null)
        {
            IQueryHandler queryHandler = QueryHandlerFactory.GetQueryHandler(handlerConfig.QueryType);

            if (handlerConfig.Configs == null || handlerConfig.Configs.Any() == false)
            {
                throw new ArgumentNullException("handlerConfig.Configs");
            }

            var context = new Context
            {
                HandlerConfig = handlerConfig,
                Configs       = handlerConfig.Configs,
                Params        = queryParams,
                ComplexData   = complexData,
            };

            ParamConvertUtil.DoConvert(context);
            var returnData = queryHandler.Query(context);

            //执行完查询后回调
            return(handlerConfig.OnQueryEnd(returnData, queryParams));
        }