Combined PK on Inline Projection #3545
Unanswered
NeussConsulting
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm doing my first steps with Marten and Wolverine and loving it so far, but it's a lot, it's complex.
I could figure out a lot on my own, but now I found something that is not part of the docu, or I was blind and didn't found it.
Let's have simple Hello World type of scenario.
I have an aggregate
`
public class UserAggregate
{
public Guid Id {get;set; }
public string Username {get;set;}
public List Processes { get; set;} = [];
public UserAggregate Apply(ProcessCreated e)
{
Process.Add(e.Process);
...
}
}
public class Process
{
public string Environment {get;set;}
public string Name {get;set;}
`
And I want to split this up into two projections
`
public class UserProjection: EventProjection
{
public User Create(IEvent input)
{
return new User { Id = input.Id, Username = input.Data.Username };
}
}
public class ProcessProjection: EventProjection
{
public Process Create(IEvent input)
{
return new Process { UserId = input.Id, Environment = input.Data.Environment, Name = input.Data.Name };
}
}
public class User
{
public Guid Id {get;set;}
public string Username {get;set;}
}
public class Process
{
public Guid UserId {get;set;}
public string Environment {get;set;}
public string Name {get;set;}
}
`
It's psuedocode, it will not compile :)
My issue is now, how do I tell Marten to create a combined Primary Key for the second table over the 3 columns, they are unique for every User, but multiple Users can have the same Processname in the same Environment.
That concept is not clear to me, how to have nice small special read only tables, what is the Query part of CQRS.
Beta Was this translation helpful? Give feedback.
All reactions