/// <summary> /// 动态生成和成员目相同的逻辑表达式并用And关联起来 /// </summary> /// <typeparam name="T">实体类型</typeparam> /// <param name="members">实体成员</param> /// <param name="logic">逻辑关系</param> /// <param name="matchValue">匹配值</param> /// <returns></returns> public static Expression <Func <T, bool> > ParseAnd <T>(string[] members, LogicEnum logic, string matchValue) { var where = WhereExtension.Parse <T>(members.FirstOrDefault(), logic, matchValue); members.Skip(1).ToList().ForEach(member => where = where.And(WhereExtension.Parse <T>(member, logic, matchValue))); return(where); }
/// <summary> /// 动态生成和匹配参数数目相同的逻辑表达式并用Or关联起来 /// </summary> /// <typeparam name="T">实体类型</typeparam> /// <param name="member">实体成员</param> /// <param name="logic">逻辑关系</param> /// <param name="matchValues">匹配值</param> /// <returns></returns> public static Expression <Func <T, bool> > ParseOr <T>(string member, LogicEnum logic, params string[] matchValues) { var where = WhereExtension.Parse <T>(member, logic, matchValues.FirstOrDefault()); matchValues.Skip(1).ToList().ForEach(value => where = where.Or(WhereExtension.Parse <T>(member, logic, value))); return(where); }