Exemplo n.º 1
0
        /// <summary>
        /// 把一个 Linq 查询转换为 IQuery 查询。
        /// </summary>
        /// <param name="queryable"></param>
        /// <returns></returns>
        public IQuery ConvertToQuery(IQueryable queryable)
        {
            if (queryable.Provider != Repo.LinqProvider)
            {
                throw new InvalidProgramException(string.Format("查询所属的仓库类型应该是 {0}。", Repo.GetType()));
            }

            var expression = queryable.Expression;
            expression = Evaluator.PartialEval(expression);
            var builder = new EntityQueryBuilder(this.Repo);
            var query = builder.BuildQuery(expression);

            return query;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 把一个 Linq 查询转换为 IQuery 查询。
        /// </summary>
        /// <param name="queryable"></param>
        /// <returns></returns>
        protected IQuery ConvertToQuery(IQueryable queryable)
        {
            if (queryable.Provider != Repo.RdbDataProvider.LinqProvider)
            {
                throw new InvalidProgramException(string.Format("查询所属的仓库类型应该是 {0}。", Repo.GetType()));
            }

            var expression = queryable.Expression;

            expression = Evaluator.PartialEval(expression);
            var builder = new EntityQueryBuilder
            {
                _repo = this.Repo,
            };

            builder.BuildQuery(expression);
            var query = builder.Result;

            return(query);
        }