예제 #1
0
        /// <summary>
        /// Executes a query to get a set of entities of the specified type using a range of string identifier. Use this
        /// as a short cut instead of creating a dedicated IQuery class.
        /// </summary>
        /// <typeparam name="TEntity">type of entity to return in the dictionary</typeparam>
        /// <param name="ids">Ids of the entity to get. Null or empty values will always return an empty dictionary.</param>
        /// <param name="ex">
        /// If specified this will execute the query under
        /// the specified context. Useful for running the query under a higher privalidge account.
        /// </param>
        /// <returns>IDictionary containing any records found</returns>
        public static async Task <IDictionary <string, TEntity> > GetByIdAsync <TEntity>(this IQueryExecutor executor, IEnumerable <string> ids, IExecutionContext ex)
        {
            if (ids == null || !ids.Any())
            {
                return(new Dictionary <string, TEntity>());
            }
            var query = new GetByStringRangeQuery <TEntity>(ids);

            return(await executor.ExecuteAsync(query, ex));
        }
예제 #2
0
        /// <summary>
        /// Executes a query to get a set of entities of the specified type using a range of string identifier. Use this
        /// as a short cut instead of creating a dedicated IQuery class.
        /// </summary>
        /// <typeparam name="TEntity">type of entity to return in the dictionary</typeparam>
        /// <param name="ids">Ids of the entity to get. Null or empty values will always return an empty dictionary.</param>
        /// <returns>IDictionary containing any records found</returns>
        public static IDictionary <string, TEntity> GetById <TEntity>(this IQueryExecutor executor, IEnumerable <string> ids)
        {
            if (ids == null || !ids.Any())
            {
                return(new Dictionary <string, TEntity>());
            }
            var query = new GetByStringRangeQuery <TEntity>(ids);

            return(executor.Execute(query));
        }