MVC中构建Linq条件、排序、Selector字段过滤

时间:2022-11-14 17:19:34

代码:

System.Linq.Expressions.Expression<Func<Domain.S_ROLE, bool>> expressWhere1 = (c => c.R_NAME.Contains(keywords));
System.Linq.Expressions.Expression<Func<Domain.S_ROLE, int>> orderBy1 = c => c.R_ORDERID; Func<IQueryable<Domain.S_ROLE>, List<Domain.S_ROLE>> selector1 = (c=>c.Select(p => new Domain.S_ROLE (){ R_ID = p.R_ID, R_NAME= p.R_NAME }).ToList<Domain.S_ROLE>());

分别是 条件、排序、字段过滤。