CRUD的多数使用NHibernate s guid.comb
ID generator。 有了这一优势,我就能够在我通畅访问数据库之前查阅该数据库,并围绕与使用正常指南有关的指数分散问题。
When we introduce messaging it raises a few questions:
- Since we are sending commands to make changes to our domain layer, we don t actually have access to the "new" domain object in the UI. Often (in the case of a web application) we need it s identifier to redirect to another page. One solution would be to pass the id as part of the command (e.g. Guid.NewGuid()) but then we lose the sequential Guids that NHibernate provides.
- If we instead use an identity strategy we remove the index issue but now have no easy way of determining the id from the UI, other than subscribing to an event or executing he command synchronously, both of which are not ideal in a web application.
So I m curious what strategy other NServiceBus developers are taking. Performing some operation on an existing entity is not really a problem since we can just send a request using ajax to dispatch the command, and notify the user that everything was successful (probably). Since the page they are on already has the updated information this is enough.
However when we create a new instance of a domain object (via a command) we often need to redirect the user to a page that then retrieves the newly created entity from our database. Of course this entity may not have been saved yet (as we are processing our commands async) and we typically need an Id to perform this redirect.