lucabriguglia / OpenCQRS

.NET Standard framework to create simple and clean design. Advanced features for DDD, CQRS and Event Sourcing.
Apache License 2.0
3 stars 115 forks source link

[Question] Is it possible to customize partition key on cosmos store? #108

Open xaviersolau opened 4 years ago

xaviersolau commented 4 years ago

I would like to use other properties as partition key for cosmos store but it looks like it is hard coded in CosmosDomainDbContext :

builder.Entity<AggregateEntity>()
                .ToContainer(_settings.AggregateContainerName)
                .HasPartitionKey(p => p.Type)
                .HasNoDiscriminator();

builder.Entity<CommandEntity>()
                .ToContainer(_settings.CommandContainerName)
                .HasPartitionKey(p => p.Type)
                .HasNoDiscriminator();

builder.Entity<EventEntity>()
                .ToContainer(_settings.EventContainerName)
                .HasPartitionKey(p => p.Type)
                .HasNoDiscriminator();

Any idea ? By the way why did you chose the Type as partition key? Why not the AggregateId for example?

lucabriguglia commented 4 years ago

You are right, the AggregateId would have been the right choice. Unfortunately it's not possible at the moment but in the mean time you can create a custom provider to address that.