/// <summary> /// Process a query. /// </summary> /// <typeparam name="TResult">The type of result</typeparam> /// <param name="queryProcessor">The query processor</param> /// <param name="queryName">The name of the query</param> /// <param name="dictionary">The key/value representation of the query</param> /// <returns>The result of the query</returns> public static async Task <TResult> ProcessAsync <TResult>(this IQueryProcessor queryProcessor, string queryName, IDictionary <string, IEnumerable <string> > dictionary) { var queryType = queryProcessor.GetQueryType(queryName); if (queryType == null) { throw new QueryProcessorException($"The query type '{queryName}' could not be found"); } var query = GetQueryDictionary(dictionary, queryType).SafeToObject(queryType); if (query == null) { throw new QueryProcessorException("The dictionary could not be converted to an object"); } return(await queryProcessor.ProcessAsync((dynamic)query)); }
/// <summary> /// Process a query. /// </summary> /// <typeparam name="TResult">The type of result</typeparam> /// <param name="queryProcessor">The query processor</param> /// <param name="queryName">The name of the query</param> /// <param name="json">The JSON representation of the query</param> /// <returns>The result of the query</returns> public static async Task <TResult> ProcessAsync <TResult>(this IQueryProcessor queryProcessor, string queryName, JObject json) { var queryType = queryProcessor.GetQueryType(queryName); if (queryType == null) { throw new QueryProcessorException($"The query type '{queryName}' could not be found"); } var query = json.SafeToObject(queryType); if (query == null) { throw new QueryProcessorException("The json could not be converted to an object"); } return(await queryProcessor.ProcessAsync((dynamic)query)); }