Exemplo n.º 1
0
		/// <summary>
		/// 完成动态SQL语句中子语句的拼接 和 参数信息的取出
		/// </summary>
		/// <param name="request"></param>
		/// <param name="parameterObject"></param>
		/// <returns></returns>
		private string Process(RequestScope request, object parameterObject) 
		{
			SqlTagContext ctx = new SqlTagContext();
            IList<ISqlChild> localChildren = children;

			ProcessBodyChildren(request, ctx, parameterObject, localChildren);

                    #region 所有参数对应的属性类的集合信息放入到ParameterMap中
            // Builds a 'dynamic' ParameterMap
            ParameterMap parameterMap = new ParameterMap(
                statement.Id + "-InlineParameterMap",
                statement.ParameterClass.FullName,
                string.Empty,
                statement.ParameterClass,
                dataExchangeFactory.GetDataExchangeForClass(null),
                usePositionalParameters);

            // Adds 'dynamic' ParameterProperty
            IList parameters = ctx.GetParameterMappings();
            int count = parameters.Count;
            for (int i = 0; i < count; i++)
            {
                parameterMap.AddParameterProperty((ParameterProperty)parameters[i]);
            }
            request.ParameterMap = parameterMap;
            #endregion

                    #region 完整的SQL语句
            string dynSql = ctx.BodyText;

            if (statement is Procedure)
            {
                dynSql = dynSql.Replace(MARK_TOKEN, string.Empty).Replace(COMMA_TOKEN, string.Empty).Trim();
            }

            // Processes $substitutions$ after DynamicSql
            if (SimpleDynamicSql.IsSimpleDynamicSql(dynSql))
            {
                dynSql = new SimpleDynamicSql(
                    dataExchangeFactory,
                    dbHelperParameterCache,
                    dynSql,
                    statement).GetSql(parameterObject);
            }
            #endregion

			return dynSql;
		}
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="request"></param>
        /// <param name="parameterObject"></param>
        /// <returns></returns>
        private string Process(RequestScope request, object parameterObject)
        {
            SqlTagContext ctx = new SqlTagContext();
            IList<ISqlChild> localChildren = children;

            ProcessBodyChildren(request, ctx, parameterObject, localChildren);

            // Builds a 'dynamic' ParameterMap
            ParameterMap parameterMap = new ParameterMap(
                statement.Id + "-InlineParameterMap",
                statement.ParameterClass.FullName,
                string.Empty,
                statement.ParameterClass,
                dataExchangeFactory.GetDataExchangeForClass(null),
                usePositionalParameters);

            // Adds 'dynamic' ParameterProperty
            var parameters = ctx.GetParameterMappings();

            parameterMap.AddParameterProperties(parameters);

            request.ParameterMap = parameterMap;

            string dynSql = ctx.BodyText;

            if (statement is Procedure)
            {
                dynSql = dynSql.Replace(MARK_TOKEN, string.Empty).Replace(COMMA_TOKEN, string.Empty).Trim();
            }

            // Processes $substitutions$ after DynamicSql
            if (SimpleDynamicSql.IsSimpleDynamicSql(dynSql))
            {
                dynSql = new SimpleDynamicSql(
                    dataExchangeFactory,
                    dbHelperParameterCache,
                    dynSql,
                    statement).GetSql(parameterObject);
            }
            return dynSql;
        }