using Microsoft.EntityFrameworkCore.Query; namespace DysonNetwork.Shared.Data; public static class OptionalQueryExtensions { public static IQueryable If( this IQueryable source, bool condition, Func, IQueryable> transform ) { return condition ? transform(source) : source; } public static IQueryable If( this IIncludableQueryable source, bool condition, Func, IQueryable> transform ) where T : class { return condition ? transform(source) : source; } public static IQueryable If( this IIncludableQueryable> source, bool condition, Func>, IQueryable> transform ) where T : class { return condition ? transform(source) : source; } }