示例#1
0
        /// <summary>
        /// Enables a gpu query.
        /// </summary>
        /// <typeparam name="TSource">The type of the elements in the source array.</typeparam>
        /// <param name="source">An array to convert to an IGpuQueryExpr.</param>
        /// <returns>A query that returns the elements of the source array.</returns>
        public static ICloudQueryExpr <IEnumerable <TSource> > AsCloudQueryExpr <TSource>(this IEnumerable <TSource> source)
        {
            //return new CloudQueryExpr<IEnumerable<TSource>>(QueryExpr.NewSource(Expression.Constant(source), typeof(TSource), QueryExprType.Sequential));
            var cq = CloudQueryExpr.NewSource(Expression.Constant(source).AsSerializable(), typeof(TSource), QueryExprType.Sequential);

            return(new CloudQueryExpr <IEnumerable <TSource> >(cq));
        }
示例#2
0
        /// <summary>
        /// Creates a new query that filters a sequence of values based on a predicate.
        /// </summary>
        /// <typeparam name="TSource">The type of the elements of source.</typeparam>
        /// <param name="query">An query whose values to filter.</param>
        /// <param name="predicate">A function to test each element for a condition.</param>
        /// <returns>A query that contains elements from the input query that satisfy the condition.</returns>
        public static ICloudQueryExpr <IEnumerable <TSource> > Where <TSource>(this ICloudQueryExpr <IEnumerable <TSource> > query, Expression <Func <TSource, bool> > predicate)
        {
            var cq = CloudQueryExpr.NewFilter(predicate.AsSerializable(), query.Expr);

            return(new CloudQueryExpr <IEnumerable <TSource> >(cq));
        }
示例#3
0
        /// <summary>
        /// Creates a new query that projects each element of a sequence into a new form.
        /// </summary>
        /// <typeparam name="TSource">The type of the elements of the query.</typeparam>
        /// <typeparam name="TResult">The type of the value returned by selector.</typeparam>
        /// <param name="query">A query whose values to invoke a transform function on.</param>
        /// <param name="selector">A transform function to apply to each element.</param>
        /// <returns>A query whose elements will be the result of invoking the transform function on each element of source.</returns>
        public static ICloudQueryExpr <IEnumerable <TResult> > Select <TSource, TResult>(this ICloudQueryExpr <IEnumerable <TSource> > query, Expression <Func <TSource, TResult> > selector)
        {
            var cq = CloudQueryExpr.NewTransform(selector.AsSerializable(), query.Expr);

            return(new CloudQueryExpr <IEnumerable <TResult> >(cq));
        }
示例#4
0
        public static ICloudQueryExpr <IEnumerable <int> > Range(int start, int count)
        {
            var cq = CloudQueryExpr.NewRangeGenerator(Expression.Constant(start).AsSerializable(), Expression.Constant(count).AsSerializable());

            return(new CloudQueryExpr <IEnumerable <int> >(cq));
        }