From 08ec531e36a1943938fdb27d6c54a2e49ff7a35c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Wed, 4 Apr 2018 16:59:32 +0300 Subject: [PATCH] Added AbpEntityFrameworkQueryableExtensions.IncludeIf --- .../AbpEntityFrameworkQueryableExtensions.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/Volo.Abp.EntityFrameworkCore/Microsoft/EntityFrameworkCore/AbpEntityFrameworkQueryableExtensions.cs 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; + } + } +}