Exemple #1
0
        /// <summary>
        /// 向原始查询附加额外的查询条件。
        /// </summary>
        /// <typeparam name="TOriginalElementType">query 查询的原始元素类型</typeparam>
        /// <param name="source">一个原始查询的数据源。</param>
        /// <param name="query">需要附加的查询条件。</param>
        /// <returns>附加完毕查询的数据源。</returns>
        public static IQueryable Attach <TOriginalElementType>(this IQueryable source, IQueryable query)
        {
            var attacher = new ExpressionAttacher();

            attacher.DataSource = source;

            var parser = attacher.Attach(typeof(TOriginalElementType), query.Expression);

            return(parser.DataSource);
        }
        public object Execute(Expression expression)
        {
            var attacher = new ExpressionAttacher
            {
                DataSource = DataSource()
            };

            var parser = attacher.Attach(OriginalElementType, expression);

            return(parser.Value);
        }
Exemple #3
0
        /// <summary>
        /// 向原始查询附加额外的查询条件。
        /// </summary>
        /// <param name="source">一个原始查询的数据源。</param>
        /// <param name="query">需要附加的查询条件:ConvertQueryable 类型。</param>
        /// <returns>附加完毕查询的数据源。</returns>
        public static IQueryable Attach(this IQueryable source, IQueryable query)
        {
            if (!(query is IElementTypeProvider))
            {
                throw new ArgumentException("The query is not ConvertQueryable<T> type.");
            }

            var attacher = new ExpressionAttacher();

            attacher.DataSource = source;

            var parser = attacher.Attach((query as IElementTypeProvider).OriginalElementType, query.Expression);

            return(parser.DataSource);
        }