Ejemplo n.º 1
0
        private void InitByMap(AbstractRequestContext requestContext, SqlMap sqlMap)
        {
            if (!string.IsNullOrEmpty(requestContext.CacheId))
            {
                SetCache(requestContext, sqlMap);
            }

            if (!String.IsNullOrEmpty(requestContext.ParameterMapId))
            {
                var fullParameterMapIdId = $"{requestContext.Scope}.{requestContext.ParameterMapId}";
                requestContext.ParameterMap = sqlMap.GetParameterMap(fullParameterMapIdId);
            }

            if (!String.IsNullOrEmpty(requestContext.ResultMapId))
            {
                var fullResultMapId = $"{requestContext.Scope}.{requestContext.ResultMapId}";
                requestContext.ResultMap = sqlMap.GetResultMap(fullResultMapId);
            }

            if (!String.IsNullOrEmpty(requestContext.MultipleResultMapId))
            {
                var fullMultipleResultMapId = $"{requestContext.Scope}.{requestContext.MultipleResultMapId}";
                requestContext.MultipleResultMap = sqlMap.GetMultipleResultMap(fullMultipleResultMapId);
            }
        }
Ejemplo n.º 2
0
        private void InitByMap(AbstractRequestContext requestContext, SqlMap sqlMap)
        {
            if (!string.IsNullOrEmpty(requestContext.CacheId))
            {
                SetCache(requestContext, sqlMap);
            }

            if (!String.IsNullOrEmpty(requestContext.ParameterMapId))
            {
                var fullParameterMapIdId = $"{requestContext.Scope}.{requestContext.ParameterMapId}";
                requestContext.ParameterMap = sqlMap.GetParameterMap(fullParameterMapIdId);
            }

            if (!String.IsNullOrEmpty(requestContext.ResultMapId))
            {
                var fullResultMapId = $"{requestContext.Scope}.{requestContext.ResultMapId}";
                requestContext.ResultMap = sqlMap.GetResultMap(fullResultMapId);
            }

            if (!String.IsNullOrEmpty(requestContext.MultipleResultMapId))
            {
                var fullMultipleResultMapId = $"{requestContext.Scope}.{requestContext.MultipleResultMapId}";
                requestContext.MultipleResultMap = sqlMap.GetMultipleResultMap(fullMultipleResultMapId);
            }

            if (!String.IsNullOrEmpty(requestContext.AutoConverterName))
            {
                if (!_smartSqlConfig.AutoConverters.TryGetValue(requestContext.AutoConverterName, out var autoConverter)
                    )
                {
                    throw new SmartSqlException(
                              $"The auto converter with name {requestContext.AutoConverterName} was not found");
                }

                requestContext.AutoConverter = autoConverter;
            }
            else if (requestContext.Statement?.AutoConverter != null)
            {
                requestContext.AutoConverter = requestContext.Statement.AutoConverter;
            }
            else
            {
                requestContext.AutoConverter = sqlMap?.AutoConverter;
            }
        }