|
|
|
@ -494,24 +494,12 @@ namespace Volo.Abp.EntityFrameworkCore |
|
|
|
|
|
|
|
if (typeof(ISoftDelete).IsAssignableFrom(typeof(TEntity))) |
|
|
|
{ |
|
|
|
/* This condition should normally be defined as below: |
|
|
|
* !IsSoftDeleteFilterEnabled || !((ISoftDelete) e).IsDeleted |
|
|
|
* But this causes a problem with EF Core (see https://github.com/aspnet/EntityFrameworkCore/issues/9502)
|
|
|
|
* So, we made a workaround to make it working. It works same as above. |
|
|
|
*/ |
|
|
|
|
|
|
|
Expression<Func<TEntity, bool>> softDeleteFilter = e => !((ISoftDelete)e).IsDeleted || ((ISoftDelete)e).IsDeleted != IsSoftDeleteFilterEnabled; |
|
|
|
expression = expression == null ? softDeleteFilter : CombineExpressions(expression, softDeleteFilter); |
|
|
|
expression = e => !IsSoftDeleteFilterEnabled || !((ISoftDelete) e).IsDeleted; |
|
|
|
} |
|
|
|
|
|
|
|
if (typeof(IMultiTenant).IsAssignableFrom(typeof(TEntity))) |
|
|
|
{ |
|
|
|
/* This condition should normally be defined as below: |
|
|
|
* !IsMayHaveTenantFilterEnabled || ((IMayHaveTenant)e).TenantId == CurrentTenantId |
|
|
|
* But this causes a problem with EF Core (see https://github.com/aspnet/EntityFrameworkCore/issues/9502)
|
|
|
|
* So, we made a workaround to make it working. It works same as above. |
|
|
|
*/ |
|
|
|
Expression<Func<TEntity, bool>> multiTenantFilter = e => ((IMultiTenant)e).TenantId == CurrentTenantId || (((IMultiTenant)e).TenantId == CurrentTenantId) == IsMultiTenantFilterEnabled; |
|
|
|
Expression<Func<TEntity, bool>> multiTenantFilter = e => !IsMultiTenantFilterEnabled || ((IMultiTenant) e).TenantId == CurrentTenantId; |
|
|
|
expression = expression == null ? multiTenantFilter : CombineExpressions(expression, multiTenantFilter); |
|
|
|
} |
|
|
|
|
|
|
|
|