コード例 #1
0
        /// <summary>
        /// Project
        /// </summary>
        /// <param name="records"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        private IEnumerable <VariantValue> Project(IEnumerable <VariantValue> records,
                                                   SqlSelectParser.ParseContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            // TODO: Implement projection

            return(records);
        }
コード例 #2
0
        /// <summary>
        /// Where
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="records"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        private IEnumerable <T> Select <T>(IEnumerable <T> records,
                                           SqlSelectParser.ParseContext context)
        {
            var pe = Expression.Parameter(typeof(T));

            // Top
            if (context.selectList().topExpr() != null)
            {
                var maxCount = double.Parse(context.selectList().topExpr().maxCount().GetText(),
                                            CultureInfo.InvariantCulture);
                records = records.Take((int)maxCount);
            }

            // Where
            if (context.expr() != null)
            {
                var where = (Expression <Func <T, bool> >)Expression.Lambda(
                    ParseWhereExpression(pe, context.expr()), pe);
                var compiled = where.Compile();
                records = records.Where(compiled);
            }

            return(records);
        }