From 06be6efa316f3a02c1b235f7cb922d8d71dbb59f Mon Sep 17 00:00:00 2001 From: Erik Shafer Date: Wed, 12 Jun 2024 07:52:08 -0500 Subject: [PATCH 1/4] removed the depredated Version field --- docker-compose.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 81a92cb..ee71c32 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,4 @@ -version: "3.4" - -services: +services: app01-inmemory: build: dockerfile: StudentEnrollment01.InMemory/Dockerfile From 0ac1a65c6464df1eb4b9889809e6a7328709b4ef Mon Sep 17 00:00:00 2001 From: Erik Shafer Date: Wed, 12 Jun 2024 07:52:27 -0500 Subject: [PATCH 2/4] swapped ordering of applies to match elsewhere --- StudentEnrollment03.Esdb/Student.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/StudentEnrollment03.Esdb/Student.cs b/StudentEnrollment03.Esdb/Student.cs index 27a9228..1336889 100644 --- a/StudentEnrollment03.Esdb/Student.cs +++ b/StudentEnrollment03.Esdb/Student.cs @@ -18,12 +18,12 @@ public void Apply(Event @event) case StudentCreated created: Apply(created); break; - case StudentEmailChanged emailChanged: - Apply(emailChanged); - break; case StudentEnrolled enrolled: Apply(enrolled); break; + case StudentEmailChanged emailChanged: + Apply(emailChanged); + break; case StudentWithdrew withdrawn: Apply(withdrawn); break; From 0f15e07ab240de3785af8e341ab220b120f21f71 Mon Sep 17 00:00:00 2001 From: Erik Shafer Date: Wed, 12 Jun 2024 07:53:36 -0500 Subject: [PATCH 3/4] for time being removed the look at StreamRevision'ing --- StudentEnrollment03.Esdb/Program.cs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/StudentEnrollment03.Esdb/Program.cs b/StudentEnrollment03.Esdb/Program.cs index ebb48d8..ec3add1 100644 --- a/StudentEnrollment03.Esdb/Program.cs +++ b/StudentEnrollment03.Esdb/Program.cs @@ -91,7 +91,7 @@ await client.AppendToStreamAsync( streamId, StreamState.Any, - new[] { created, enrolled, enrolled2, enrolled3, emailChanged }, + new[] { created, enrolled, enrolled2, enrolled3, emailChanged, withdrawn }, cancellationToken: default ); @@ -112,23 +112,14 @@ await client.AppendToStreamAsync( // Okay, taking that StreamResult we're going to make it a List of ResolvedEvents. var eventStream = await streamResult.ToListAsync(); -// Get the last event's event number. -var lastEventNumFromStream = eventStream.Last().Event.EventNumber.ToUInt64(); - -// Append another event. This time let's make sure no one has appended to (AKA updated) the stream. -await client.AppendToStreamAsync( - streamId, - new StreamRevision(lastEventNumFromStream), // checking against expected revision number - new[] { withdrawn }, - cancellationToken: default -); +Console.WriteLine($"Events (total: {eventStream.Count}) from selected stream: "); +// Instantiate our model and then apply state changes from the deserialized events. var student = new Student(); - -Console.WriteLine($"Events (total: {eventStream.Count}) from selected stream: "); foreach (var @event in eventStream) { - switch (DeserializeEvent(@event.Event)) + var deserializeEvent = DeserializeEvent(@event.Event); + switch (deserializeEvent) { case StudentCreated studentCreated: student.Apply(studentCreated); From 2ee5646b318af42efc2ed502ecfe6efbd0d0a297 Mon Sep 17 00:00:00 2001 From: Erik Shafer Date: Wed, 12 Jun 2024 07:59:02 -0500 Subject: [PATCH 4/4] updated readme with YouTube video link --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4649745..ac343d8 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,13 @@ An application showing the absolute basics of event sourcing with [EventStoreDB (ESDB)](https://www.eventstore.com/). +The accompanying [YouTube video can be found here](https://www.youtube.com/watch?v=SB55-lgK_8I). ## 💡 Inspiration -Inspired by Nick Chapsas' video about [getting started with Event Sourcing in .NET](https://www.youtube.com/watch?v=n_o-xuuVtmw). This take however uses EventStoreDB as its, well, store of events! +This effort was inspired by Nick Chapsas' excellent video about [getting started with Event Sourcing in .NET](https://www.youtube.com/watch?v=n_o-xuuVtmw). This version however uses EventStoreDB as its database. +Be sure to check out [Nick's YouTube channel](https://www.youtube.com/@nickchapsas) if you are somehow unfamiliar with his content, as well as his education platform [Dometrain](https://dometrain.com/) where you can level up your software development skills! ### 📄 Mini-Log / 🤔 Thoughts / 🧠 Brain Dump