using System.Collections; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query; namespace DysonNetwork.Pass.Extensions; public static class OptionalQueryExtensions { public static IQueryable If< T >( this IQueryable source, bool condition, Func, IQueryable> transform ) { return condition ? transform(source) : source; } public static IQueryable If< T, TP >( this IIncludableQueryable source, bool condition, Func, IQueryable> transform ) where T : class { return condition ? transform(source) : source; } public static IQueryable If< T, TP >( this IIncludableQueryable> source, bool condition, Func>, IQueryable> transform ) where T : class { return condition ? transform(source) : source; } }