linq expression 查询生成lamda语句

            ParameterExpression x = Expression.Parameter(typeof(Custom), "x");
            Expression<Func<Custom, bool>> end = Expression.Lambda<Func<Custom, bool>>(query, new ParameterExpression[] { x });

            var c = querys.DB.Customs.Where(end);



        public ResultBase GetEntitys(Expression expression, ParameterExpression param)
        {
            ResultBase result = new ResultBase();
            result.ProgressName = "GetEntitys";
            IQueryable q=null;
            if (expression == null)
            {
                q = DBConn.DataBase.TaskBatchs;
            }
            else
            {
                q = DBConn.DataBase.TaskBatchs.Where(Expression.Lambda<Func<TaskBatch, bool>>(expression, param));
            }
           
            Query<TaskBatch>(q, ref result);
            if (result.HasError) result.Message = "读取批次失败";
            return result;
        }

原文地址:https://www.cnblogs.com/swarb/p/9924378.html