private async Task OnBeforeQueryAsync(IRepositoryQuery query, ICommandOptions options, Type resultType)
        {
            if (SupportsSoftDeletes && IsCacheEnabled && options.GetSoftDeleteMode() == SoftDeleteQueryMode.ActiveOnly)
            {
                var deletedIds = await Cache.GetListAsync <string>("deleted").AnyContext();

                if (deletedIds.HasValue)
                {
                    query.ExcludedId(deletedIds.Value);
                }
            }

            var systemFilter = query.GetSystemFilter();

            if (systemFilter != null)
            {
                query.MergeFrom(systemFilter.GetQuery());
            }

            if (BeforeQuery == null || !BeforeQuery.HasHandlers)
            {
                return;
            }

            await BeforeQuery.InvokeAsync(this, new BeforeQueryEventArgs <T>(query, options, this, resultType)).AnyContext();
        }
        private bool ShouldReturnDocument(T document, ICommandOptions options)
        {
            if (document == null)
            {
                return(true);
            }

            if (!SupportsSoftDeletes)
            {
                return(true);
            }

            var  mode = options.GetSoftDeleteMode();
            bool returnSoftDeletes = mode == SoftDeleteQueryMode.All || mode == SoftDeleteQueryMode.DeletedOnly;

            return(returnSoftDeletes || !((ISupportSoftDeletes)document).IsDeleted);
        }