private async Task <bool> OnDelete(TKey key, EntityFrameworkProjectionContext context)
        {
            TProjection existingProjection = await context.GetProjection <TProjection>(key);

            if (existingProjection != null)
            {
                var set = context.GetDbSet <TProjection>();
                set.Remove(existingProjection);
                //await context.SaveAsync().ConfigureAwait(false);
                return(true);
            }

            return(false);
        }
        private async Task OnUpdate(TKey key, EntityFrameworkProjectionContext context, Func <TProjection, Task> projector, Func <bool> createIfMissing)
        {
            TProjection projection = await context.GetProjection <TProjection>(key);

            if ((projection == null) && createIfMissing())
            {
                projection = new TProjection();
                _setIdentity(projection, key);
                await projector(projection).ConfigureAwait(false);

                //await context.SaveAsync().ConfigureAwait(false);
            }
            else
            {
                if (projection != null && Filter(projection))
                {
                    await projector(projection).ConfigureAwait(false);
                }
            }
        }
        private async Task OnCreate(TKey key, EntityFrameworkProjectionContext context, Func <TProjection, Task> projector, Func <TProjection, bool> shouldOverwrite)
        {
            TProjection projection = await context.GetProjection <TProjection>(key);

            if ((projection == null) || shouldOverwrite(projection))
            {
                if (projection == null)
                {
                    projection = new TProjection();
                    _setIdentity(projection, key);
                    await projector(projection).ConfigureAwait(false);

                    var set = context.GetDbSet <TProjection>();
                    set.Add(projection);

                    //await context.SaveAsync().ConfigureAwait(false);
                }
                else
                {
                    await projector(projection).ConfigureAwait(false);
                }
            }
        }
 public async Task ProjectEvent(object anEvent, EntityFrameworkProjectionContext context)
 {
     context.WasHandled = await _eventMap.Handle(anEvent, context).ConfigureAwait(false);
 }