1234567891011121314151617181920212223242526272829 |
- using Ant.ORM;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using System.Threading.Tasks;
- namespace MES.Production.Entity.Extensions
- {
- /// <summary>
- /// AntORMQueryableExtensions
- /// </summary>
- public static class AntORMQueryableExtensions
- {
- /// <summary>
- /// 根据第三方条件是否为真来决定是否执行指定条件的查询
- /// </summary>
- /// <param name="source"> 要查询的源 </param>
- /// <param name="predicate"> 查询条件 </param>
- /// <param name="condition"> 第三方条件 </param>
- /// <typeparam name="T"> 动态类型 </typeparam>
- /// <returns> 查询的结果 </returns>
- public static IQuery<T> WhereIf<T>(this IQuery<T> source, bool condition, Expression<Func<T, bool>> predicate)
- {
- return condition ? source.Where(predicate) : source;
- }
- }
- }
|