diff --git a/src/Volo.Abp.EntityFrameworkCore/Microsoft/EntityFrameworkCore/AbpEntityFrameworkQueryableExtensions.cs b/src/Volo.Abp.EntityFrameworkCore/Microsoft/EntityFrameworkCore/AbpEntityFrameworkQueryableExtensions.cs new file mode 100644 index 0000000000..099a80625f --- /dev/null +++ b/src/Volo.Abp.EntityFrameworkCore/Microsoft/EntityFrameworkCore/AbpEntityFrameworkQueryableExtensions.cs @@ -0,0 +1,23 @@ +using System; +using System.Linq; +using System.Linq.Expressions; + +namespace Microsoft.EntityFrameworkCore +{ + public static class AbpEntityFrameworkQueryableExtensions + { + /// + /// Specifies the related objects to include in the query results. + /// + /// The source on which to call Include. + /// A boolean value to determine to include or not. + /// The type of navigation property being included. + public static IQueryable IncludeIf(this IQueryable source, bool condition, Expression> path) + where T : class + { + return condition + ? source.Include(path) + : source; + } + } +}