C# EF结合Expression动态查询

            Expression<Func<T, bool>> exp = o => true;

             if (type==0) exp = e => e.CreateTime >= begintime && e.CreateTime <= endtime;
             if (!string.IsNullOrWhiteSpace(taskname)) exp = e => e.Name.Contains(taskname);

             var dataSource=qry.Where(exp).toList();

猜你喜欢

转载自blog.csdn.net/qq_35534449/article/details/81240404