This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I've created my first model and I'm now ready to start implementing some domain logic. I've read through the (excellent!) book, reviewed the sample code and looked through the forums but some things haven't quite clicked for me, yet. Background My server application and model will be used in a few ways;
Access by these will be via a Service layer. In this scenario, how do I implement my domain logic considering the unit of work scope will be different for each? I'm extending the model using partial classes as suggested. A skeleton for my first entity, Item, is below. Some guidance on how to proceed would be really appreciated:
|
|
|
Probably the best solution for the API you've outlined is to use dependency injection or a service locator or similar pattern. Basically you want some external (dare I say global) container that you can ask 'what is the current scope' and it will give it to you. Then you can use that in your methods:
For the container you could use something like Ninject or you could easily roll your own simple service locator -- whatever you are most familiar with. (Note by the way that I did not put a An alternative of course is to pass a unit of work object into each method. Although more cluttered, this makes the usage and lifecycle of the UOW more obvious at the calling site. A third possibility is to encapsulate the unit of work in a Repository object, and make methods like FindItemById instance methods on the repository class. |
|