Пример #1
0
        /// <summary>
        /// Generates the query.
        /// </summary>
        /// <param name="request">The query to load.</param>
        /// <returns>An object containing the sql query and other lookup data.</returns>
        private static BulkSqlQuery CreateQuery(EntityRequest request)
        {
            BulkSqlQuery query;

            // Do not require access to the individual query components
            using (new SecurityBypassContext())
            {
                try
                {
                    // Parse the request
                    EntityMemberRequest memberRequest;
                    if (request.Request != null)
                    {
                        memberRequest = request.Request;
                    }
                    else
                    {
                        memberRequest = Factory.RequestParser.ParseRequestQuery(request.RequestString);
                    }

                    // Tweak it to handle request-type-specific hacks
                    BulkRequestRunner.AdjustEntityMemberRequest(request, memberRequest);

                    // Convert the request into a bulk SQL query.
                    query = BulkRequestSqlBuilder.BuildSql(memberRequest, request.Hint);
                }
                catch (Exception ex)
                {
                    EventLog.Application.WriteError(ex.ToString());
                    throw;
                }
            }
            return(query);
        }
        /// <summary>
        /// Build the overall T-SQL query.
        /// </summary>
        /// <param name="request">The root level entity member request.</param>
        /// <param name="hintText">A hint about what this query is doing. Use for logging/diagnostics only.</param>
        public static BulkSqlQuery BuildSql(EntityMemberRequest request, string hintText = null)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            var builder = new BulkRequestSqlBuilder
            {
                _request = request,
            };

            builder.BuildSql( );

            return(builder._result);
        }