Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6811645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:21:10+00:00 2026-05-26T20:21:10+00:00

I’m trying to create a simple event store using C# and [ServiceStack] Redis. public

  • 0

I’m trying to create a simple event store using C# and [ServiceStack] Redis.

public class AggregateEvents
{
    public Guid Id { get; set;}
    public List<DomainEvent> Events { get; set; }
}

public abstract class DomainEvent { }

public class UserRegisteredEvent : DomainEvent 
{
    public Guid UserId { get; set; }
    public string Name { get; set; }
}

public class UserPromotedEvent : DomainEvent
{
    public Guid UserId { get; set; }
    public string NewRole { get; set; }
}

if I do a roots.GetAll() I get an exception because the abstract class could not be instantiated. If I turn the base class into an interface instead, the Events object is null and the objects I stored in there get lost.

Any thoughts?

Edit 1

No joy using v3.03 and this code:

    [Test]
    public void foo()
    {
        var client = new RedisClient("localhost");
        var users = client.GetTypedClient<AggregateEvents>();


        var userId = Guid.NewGuid();

        var eventsForUser = new AggregateEvents
                       {
                           Id = userId,
                           Events = new List<DomainEvent>()
                       };

        eventsForUser.Events.Add(new UserPromotedEvent { UserId = userId });


        users.Store(eventsForUser);

        var all = users.GetAll(); // exception
    }

Edit 2

Also not worked with this approach;

    [Test]
    public void foo()
    {
        var userId = Guid.NewGuid();
        var client = new RedisClient("localhost");

        client.As<DomainEvent>().Lists["urn:domainevents-" + userId].Add(new UserPromotedEvent {UserId= userId});


        var users = client.As<DomainEvent>().Lists["urn:domainevents-" + userId];

        foreach (var domainEvent in users) // exception
        {

        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:21:10+00:00Added an answer on May 26, 2026 at 8:21 pm

    Can you try again with the latest version (v3.05+) of the ServiceStack Redis client:

    https://github.com/ServiceStack/ServiceStack.Redis/downloads

    The ServiceStack Json Serializer which the client uses has just added support for deserialization of Abstract/interface types which will be in the latest version of the client.

    Note: this works by embedding __type information into the JSON payload which tells the serializer what concrete class it should deserialize into. It only embeds this information for Abstract/interface/object types. So you when you serialize you will need to cast to the abstract type, e.g:

    redis.Store((DomainEvent)userPromoEvent);
    

    or if adding to a list:

    redis.As<DomainEvent>().Lists["urn:domainevents"].Add(userPromoEvent);
    

    These examples now work as indicated by the newly added DomainEvents Unit Tests 🙂

    [Test]
    public void Can_Retrieve_DomainEvents()
    {
        var userId = Guid.NewGuid();
        var client = new RedisClient("localhost");
        client.FlushAll();
    
        client.As<DomainEvent>().Lists["urn:domainevents-" + userId].Add(
            new UserPromotedEvent { UserId = userId });
    
        var users = client.As<DomainEvent>().Lists["urn:domainevents-" + userId];
    
        Assert.That(users.Count, Is.EqualTo(1));
    
        var userPromoEvent = (UserPromotedEvent)users[0];
        Assert.That(userPromoEvent.UserId, Is.EqualTo(userId));
    }
    
    
    [Test]
    public void Can_from_Retrieve_DomainEvents_list()
    {
        var client = new RedisClient("localhost");
        var users = client.As<AggregateEvents>();
    
        var userId = Guid.NewGuid();
    
        var eventsForUser = new AggregateEvents
        {
            Id = userId,
            Events = new List<DomainEvent>()
        };
    
        eventsForUser.Events.Add(new UserPromotedEvent { UserId = userId });
    
        users.Store(eventsForUser);
    
        var all = users.GetAll(); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.