Comments (5)
Actually we have in Jarvis aggregates with no default constructor, we have a factory that use default constructor or uses Castle.Windsor to resolve with optional external services.
We never have initialization in constructor with some properties that have business meaning. In your example you have a
public person(string name)
And we would never have such constructor in an aggregate, we will use the default aggregate and then call some method like SetName, or whatever. In such a situation some of the events should be raised in the constructor, and is a situation we do not want to handle. The constructor is there only to inject external dependencies and nothing related to business or something that should raise events.
The init is called by the repository, the situation we have is that no aggregate is created outside of the repository (except for testing).
You can always use a custom aggregate factory if you really need to use some special constructors.
Alk.
from nstore.
If I do something like this:
var p = new Person();
p.SetName("mauro");
where SetName
is defined as:
public void SetName(string name)
{
Emit(new NameChanged( name ));
}
and PersonState
is as:
public class PersonState
{
private void On(NameChanged @event){ ... }
}
A NRE
is thrown, inspecting with the debugger the aggregate State
protected property is null, looking at source code State
is instantiated only when Init
is called. Thus the question, do I need to manually call Init
.
from nstore.
I think I understood, a call to Repository.GetByIdAsync<TAggregate>
is mandatory, if the aggregate doesn't exist it'll be created and returned to the caller, initialized.
from nstore.
from nstore.
Thanks
from nstore.
Related Issues (20)
- Add method to query for more than one PartitionId HOT 1
- [Polling] Position in Completed-Events is reset on multiple Polls HOT 1
- Store Payload as Binary data on Sqlite
- Reduce allocation on sqlstring
- Avoid throwing exception on Delete if stream is missing HOT 1
- Add Travis CI build for MacOs & Linux HOT 1
- NStore.Persistence.MsSql/0.2.0-sqlitebinary0111 nuget package is failing to install with obscure error HOT 5
- Tests do not run in Cake build but runs perfectly in VS and dotnet test HOT 1
- Error logging skipping hole
- Mongodb: Limit logging in case of errors
- LambdaSubscription, wrong FailedPosition
- Race Condition on filler
- Another probably race condition on filler. HOT 1
- Lambda subscription - never recovers from error
- Typo in IMsSqlPayloadSearializer && ISqlPayloadSearializer
- Enable support for external transaction
- Disable idempotency on streams HOT 1
- Error with empty database and multiple processes working HOT 1
- Microsoft.Data.SqlClient support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nstore.