public void SaveAggregate <TAggregate>(Guid id) where TAggregate : IAggregateRoot { var aggregate = AggregateStore.Where(x => x.Id == id).FirstOrDefault(); if (aggregate == null) { aggregate = new AggregateStoreModel { Id = id, Type = typeof(TAggregate).AssemblyQualifiedName }; AggregateStore.Add(aggregate); } else { AggregateStore.Remove(aggregate); } }