/// <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> /// A shorthand fetch a filtered list of resources of the provided type alias. /// </summary> /// <param name="typeAlias">The type of entities to fetch</param> /// <param name="filter">The filter to apply</param> /// <param name="requestString">The request string.</param> /// <returns> /// The entity refs that match the filter /// </returns> public static IEnumerable <EntityRef> FetchFilteredEntities(string typeAlias, string filter, string requestString = null) { var request = new EntityRequest(typeAlias, "id", QueryType.FilterInstances, "BulkRequestRunner FetchFilteredEntites"); request.Filter = filter; var controls = BulkRequestRunner.GetEntities(request); return(controls.Select(ed => ed.Id)); }