diff --git a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/EventSourcing.PoC.Application.csproj b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/EventSourcing.PoC.Application.csproj
index 25d7de0..445ba8f 100644
--- a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/EventSourcing.PoC.Application.csproj
+++ b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/EventSourcing.PoC.Application.csproj
@@ -56,11 +56,11 @@
..\packages\Nito.Disposables.1.2.3\lib\netstandard2.0\Nito.Disposables.dll
-
- ..\packages\RdbmsEventStore.0.5.0\lib\net461\RdbmsEventStore.dll
+
+ ..\packages\RdbmsEventStore.0.6.0-beta0001.222\lib\net461\RdbmsEventStore.dll
-
- ..\packages\RdbmsEventStore.EntityFramework.0.5.0\lib\net461\RdbmsEventStore.EntityFramework.dll
+
+ ..\packages\RdbmsEventStore.EntityFramework.0.6.0-beta0001.222\lib\net461\RdbmsEventStore.EntityFramework.dll
diff --git a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/Messaging/LatestMessageQueryHandler.cs b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/Messaging/LatestMessageQueryHandler.cs
index 27e8feb..6075b88 100644
--- a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/Messaging/LatestMessageQueryHandler.cs
+++ b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/Messaging/LatestMessageQueryHandler.cs
@@ -1,4 +1,5 @@
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using EventSourcing.PoC.Application.Events;
using MediatR;
@@ -6,16 +7,16 @@
namespace EventSourcing.PoC.Application.Messaging
{
- public class LatestMessageQueryHandler : IAsyncRequestHandler
+ public class LatestMessageQueryHandler : IRequestHandler
{
- private readonly IEventStream> _eventStream;
+ private readonly IEventStore> _eventStream;
- public LatestMessageQueryHandler(IEventStream> eventStream)
+ public LatestMessageQueryHandler(IEventStore> eventStream)
{
_eventStream = eventStream;
}
- public async Task Handle(LatestMessageQuery _)
+ public async Task Handle(LatestMessageQuery _, CancellationToken token)
{
var events = await _eventStream.Events("1");
var message = events.Aggregate("", (current, evt) =>
diff --git a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/Messaging/PostMessageCommand.cs b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/Messaging/PostMessageCommand.cs
index 038fbe9..bb9f0bf 100644
--- a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/Messaging/PostMessageCommand.cs
+++ b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/Messaging/PostMessageCommand.cs
@@ -4,13 +4,11 @@ namespace EventSourcing.PoC.Application.Messaging
{
public class PostMessageCommand : IRequest
{
- public PostMessageCommand(string message, long currentVersion)
+ public PostMessageCommand(string message)
{
Message = message;
- CurrentVersion = currentVersion;
}
public string Message { get; }
- public long CurrentVersion { get; }
}
}
\ No newline at end of file
diff --git a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/Messaging/PostMessageCommandHandler.cs b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/Messaging/PostMessageCommandHandler.cs
index cf18275..52f1b7e 100644
--- a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/Messaging/PostMessageCommandHandler.cs
+++ b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/Messaging/PostMessageCommandHandler.cs
@@ -1,4 +1,6 @@
using System;
+using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using EventSourcing.PoC.Application.Events;
using MediatR;
@@ -6,18 +8,31 @@
namespace EventSourcing.PoC.Application.Messaging
{
- public class PostMessageCommandHandler : IAsyncRequestHandler
+ public class PostMessageCommandHandler : IRequestHandler
{
- private readonly IEventStream> _eventWriter;
+ private readonly IEventStore> _eventWriter;
- public PostMessageCommandHandler(IEventStream> eventWriter)
+ public PostMessageCommandHandler(IEventStore> eventWriter)
{
_eventWriter = eventWriter;
}
- public Task Handle(PostMessageCommand command)
- => !string.IsNullOrWhiteSpace(command.Message)
- ? _eventWriter.Append("1", command.CurrentVersion, new MessagePostedEvent { Message = command.Message })
- : throw new ArgumentException("Posting empty messages is not allowed");
+ public async Task Handle(PostMessageCommand command, CancellationToken token)
+ {
+ if (string.IsNullOrWhiteSpace(command.Message))
+ {
+ throw new ArgumentException("Posting empty messages is not allowed");
+ }
+
+ var currentVersion = (await _eventWriter.Events("1")).Select(e => e.Timestamp)
+ .DefaultIfEmpty(DateTimeOffset.MinValue)
+ .Max() as DateTimeOffset?;
+
+ if (currentVersion == DateTimeOffset.MinValue)
+ {
+ currentVersion = null;
+ }
+ await _eventWriter.Append("1", currentVersion, new MessagePostedEvent {Message = command.Message});
+ }
}
}
\ No newline at end of file
diff --git a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/packages.config b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/packages.config
index 27b1bed..683e13f 100644
--- a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/packages.config
+++ b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Application/packages.config
@@ -7,8 +7,8 @@
-
-
+
+
diff --git a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Persistence/EventSourcing.PoC.Persistence.csproj b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Persistence/EventSourcing.PoC.Persistence.csproj
index 8cd6820..c5baf6a 100644
--- a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Persistence/EventSourcing.PoC.Persistence.csproj
+++ b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Persistence/EventSourcing.PoC.Persistence.csproj
@@ -53,11 +53,11 @@
..\packages\Nito.Disposables.1.2.3\lib\netstandard2.0\Nito.Disposables.dll
-
- ..\packages\RdbmsEventStore.0.5.0\lib\net461\RdbmsEventStore.dll
+
+ ..\packages\RdbmsEventStore.0.6.0-beta0001.222\lib\net461\RdbmsEventStore.dll
-
- ..\packages\RdbmsEventStore.EntityFramework.0.5.0\lib\net461\RdbmsEventStore.EntityFramework.dll
+
+ ..\packages\RdbmsEventStore.EntityFramework.0.6.0-beta0001.222\lib\net461\RdbmsEventStore.EntityFramework.dll
diff --git a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Persistence/EventsContext.cs b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Persistence/EventsContext.cs
index 868de87..eb8b5db 100644
--- a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Persistence/EventsContext.cs
+++ b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Persistence/EventsContext.cs
@@ -2,7 +2,7 @@
namespace EventSourcing.PoC.Persistence
{
- public class EventsContext : EventStoreContext
+ public class EventsContext : EntityFrameworkEventStoreContext
{
public EventsContext() : base("name=EventSourcingPoC") { }
}
diff --git a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Persistence/packages.config b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Persistence/packages.config
index 21c0f41..955019c 100644
--- a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Persistence/packages.config
+++ b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Persistence/packages.config
@@ -6,8 +6,8 @@
-
-
+
+
diff --git a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Web/Configuration/ServiceRegistrations/EventSourcingModule.cs b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Web/Configuration/ServiceRegistrations/EventSourcingModule.cs
index 65d4a7f..2de1c6f 100644
--- a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Web/Configuration/ServiceRegistrations/EventSourcingModule.cs
+++ b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Web/Configuration/ServiceRegistrations/EventSourcingModule.cs
@@ -17,7 +17,7 @@ public class EventSourcingModule : Module
{
protected override void Load(ContainerBuilder builder)
{
- builder.RegisterAssemblyTypes(typeof(IEventStream<,,>).GetTypeInfo().Assembly).AsImplementedInterfaces().SingleInstance();
+ builder.RegisterAssemblyTypes(typeof(IEventStore<,,>).GetTypeInfo().Assembly).AsImplementedInterfaces().SingleInstance();
builder.RegisterInstance(new TranslatingEventRegistry(
new Dictionary
diff --git a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Web/Configuration/ServiceRegistrations/MediatRModule.cs b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Web/Configuration/ServiceRegistrations/MediatRModule.cs
index fc33910..7f697d9 100644
--- a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Web/Configuration/ServiceRegistrations/MediatRModule.cs
+++ b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Web/Configuration/ServiceRegistrations/MediatRModule.cs
@@ -25,13 +25,8 @@ protected override void Load(ContainerBuilder builder)
var mediatrOpenTypes = new[]
{
typeof(IRequestHandler<>),
- typeof(IAsyncRequestHandler<>),
typeof(IRequestHandler<,>),
- typeof(IAsyncRequestHandler<,>),
- typeof(ICancellableAsyncRequestHandler<,>),
- typeof(INotificationHandler<>),
- typeof(IAsyncNotificationHandler<>),
- typeof(ICancellableAsyncNotificationHandler<>)
+ typeof(INotificationHandler<>)
};
foreach (var markerType in _markerTypes)
diff --git a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Web/EventSourcing.PoC.Web.csproj b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Web/EventSourcing.PoC.Web.csproj
index 3dccd90..469f0e6 100644
--- a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Web/EventSourcing.PoC.Web.csproj
+++ b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Web/EventSourcing.PoC.Web.csproj
@@ -100,11 +100,11 @@
..\packages\Owin.1.0\lib\net40\Owin.dll
-
- ..\packages\RdbmsEventStore.0.5.0\lib\net461\RdbmsEventStore.dll
+
+ ..\packages\RdbmsEventStore.0.6.0-beta0001.222\lib\net461\RdbmsEventStore.dll
-
- ..\packages\RdbmsEventStore.EntityFramework.0.5.0\lib\net461\RdbmsEventStore.EntityFramework.dll
+
+ ..\packages\RdbmsEventStore.EntityFramework.0.6.0-beta0001.222\lib\net461\RdbmsEventStore.EntityFramework.dll
..\packages\System.Collections.Immutable.1.4.0\lib\netstandard2.0\System.Collections.Immutable.dll
diff --git a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Web/packages.config b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Web/packages.config
index 34b7892..02d5b1e 100644
--- a/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Web/packages.config
+++ b/samples/ASP.NET WebApi 2 with EF 6/EventSourcing.PoC.Web/packages.config
@@ -27,8 +27,8 @@
-
-
+
+