Belvasis,If you need a place where share a post about another solution than CpBT let me know. You can post your solution and code in NH-Forge, really. More than one option is always welcome and in general people sharing his code and his experience are welcome in NH-Forge.
2009/8/23 Belvasis <[email protected]> > I know this blog and the video and it is fine. As I said I will rethink the > CpBT<http://fabiomaulo.blogspot.com/2008/12/implementing-conversation-per-business.html>. > Maybe the name "UseCase" from > my last post is a little misleading. The "UseCase" is more a "ICommand" > compared to the example. It is just > decoupled from the ViewModel to simplify configuration, permission control, > dependency checking etc. As part of > the infrastructure of the app it allows to extend the application in a > simple way, without touching any existing code. > The "real" Model's and Repositories are looking similiar to the one from > the example. In the end I think we come > to the same result, but as i read it now, i think the CpBT approach is more > elegant and robust. Thanks > > > 2009/8/23 Fabio Maulo <[email protected]> > >> did you see the video ?Now have a look on how look the IRepository and >> the Model (the UseCase) >> http://jfromaniello.blogspot.com/2009/08/nhibernate-and-wpf-cpbt.html >> >> <http://jfromaniello.blogspot.com/2009/08/nhibernate-and-wpf-cpbt.html>All >> is working with MVVM databing, Observable collection, error providers and so >> on but.... >> but entities look as: >> >> http://code.google.com/p/unhaddins/source/browse/trunk/Examples/uNHAddIns.Examples.WPF/ChinookMediaManager.Domain/Album.cs >> >> 2009/8/23 Fabio Maulo <[email protected]> >> >> Belvasis,have a look to the video at the bottom of the post >>> >>> http://jfromaniello.blogspot.com/2009/08/nhibernate-and-wpf-viewmodels-and-views.html >>> >>> >>> 2009/8/23 Belvasis <[email protected]> >>> >>> Hm i tried to write a winform framework (mostly) independend of NH. My >>>> attemp was that the hole session thing >>>> is transparent for the developer, so that all one has to know about NH >>>> is the ICriteria interface. So i have >>>> a IPersistenceService that is resolved by IoC. The Service has a method >>>> OpenSession wich returns an >>>> IPersistenceSession (no NH Session). The IPersistenceSession holds an >>>> IPersistenceContext wich in case >>>> of NH usage manages the ISession for the IPersistenceSession. So every >>>> UseCase works with such a >>>> IPersistenceSession and resolves IRepository<T> instances from it. Every >>>> IRepository<T> instance is valid >>>> only within this IPersistenceSession/IPersistenceContext. If one >>>> resolves an IRepository<T> directly from >>>> the IoC container, it uses it's owen independend IPersistenceSession. >>>> The Winform stuff is build like MVC. The views are simply usercontrols >>>> implementing an IContentView interface. >>>> Views are managed by the controller wich is a IUseCase instance and live >>>> in a main ContenView ( IWorkbench). >>>> The Workbench provides the CallingContext to the IUseCase. The IUseCase >>>> builds an ExecutionContext from >>>> this CallingContext or retrieves one if it is called by another >>>> IUseCase. The ExecutionContext simply contains >>>> a IWorkbench reference and a reference to the calling IUseCase. Since >>>> the IUseCase has also a reference >>>> to an IPersistenceSession it can simply be used by child UseCase's. The >>>> workbench itself is build from an >>>> IUseCaseSchema wich contains a tree of IUseCaseItems where every item >>>> may reference a IUseCaseDefinition. >>>> The IUseCaseDefinition can be used to build and execute the IUseCase, >>>> wich is done by the IUseCaseRepository, >>>> since there is some proxy stuff involved to manage permission and other >>>> dependencies. >>>> So in the end it looks like this: >>>> >>>> IWorkbench >>>> ---> IUseCaseSchema >>>> ---> IUseCaseItem >>>> ---> Button/Treenode, Menue etc. >>>> ---> Click (:-)) >>>> ---> >>>> IUseCaseRepository.doBuildUseCase(Definition,CallingContext) >>>> ---> IUseCase.doExecute >>>> ---> IPersistenceService.OpenSession >>>> ---> do things...or >>>> ---> create IContentView >>>> ---> ContentView.PersistenceSession = >>>> IUseCase.PersistenceSession >>>> ---> IWorkbench.doAddView(ContentView) >>>> ---> ContentView...Button...is again an >>>> IUseCaseItem with IUseCaseDefinition... Click... >>>> ---> >>>> IUseCase.doExecuteChildUseCase(Definition, >>>> ExecutionContext)...ExecutionContext.Entity = Currently selected entity >>>> ---> this.PersistenceSession = >>>> ExecutionContext.PersistenceSession >>>> ---> work with the ExecutionContext.Entity >>>> - OR - >>>> ---> this.PersistenceSession = >>>> IPersistenceService.OpenSession >>>> ---> reload the Entity within the newly >>>> created IPersistenceSession >>>> ( >>>> IPersistenceSession.getRepository<T>().getObject( >>>> ExecutionContext.Entity.ID) >>>> ---> do soemthing usefull >>>> ---> close >>>> view....IWorkbench.doRemoveView(ContentView) >>>> ---> IUseCase.doStop >>>> ---> Click another Item >>>> ---> IUseCase.doPause >>>> ---> build and execute another IUseCase >>>> >>>> So i don't know if this is all a little naive and therefore i didn't >>>> post anything about it. It works well, but i will >>>> rethink the pattern from Fabio if or how it fits in all this. I'm just a >>>> little carefully :-) >>>> >>>> 2009/8/23 Jim Tanner <[email protected]> >>>> >>>> >>>>> @Tuna : I don't find any mention of winform around caliburn but i may >>>>> be mistaken. Are u sure they mix well before i digg further ? >>>>> >>>>> @Carlos : By any chance did u try the winform sample inside NhContrib >>>>> (not unhaddins)? Do u remember getting it work or was it broken ? >>>>> >>>>> @ChrisHolmes and Belvasis : Are you writting / have you written a >>>> winform nh framework from scratch or can u point me to an existing >>>> framework ? >>>> >>>>> >>>>> @Every one who might be interrested : This article deals with a way to >>>>> handle lazy loading in winforms. >>>>> http://www.codeproject.com/KB/cs/NHibernateLazyInitializer.aspx >>>>> >>>>> >>>>> >>>>> On 23 août, 18:13, Carlos cubas <[email protected]> wrote: >>>>> > I think foremost, you should tone down your demanding attitude. >>>>> Everybody is willing to help you just not with you demanding such >>>>> attention. >>>>> > >>>>> > Again, you should really take a close look at the unhaddins impl, run >>>>> the samples, etc. I was in the same boat as you some time ago. And >>>>> managed >>>>> to figure it out. It can't be that hard can it? >>>>> > >>>>> > -Carlos >>>>> > >>>>> > Practice makes perfect, but if no one is perfect, why practice? >>>>> > >>>>> > > Date: Sun, 23 Aug 2009 08:50:34 -0700 >>>>> > > Subject: [nhusers] Re: How to handle Session in WinForm project? >>>>> > > From: [email protected] >>>>> > > To: [email protected] >>>>> > >>>>> > > > If you are all new to this, don't try to invent everything from >>>>> > > > scratch in your first application. Either use the patterns and >>>>> > > > libraries already mentioned or, if you want to really understand >>>>> and >>>>> > > > develop everything yourself, start simple. >>>>> > >>>>> > > Yes! Because understanding is the most important thing! I am not >>>>> going >>>>> > > to just grab other people's bits and implementations without >>>>> > > understanding them and start using them. That is not how I grow as >>>>> a >>>>> > > developer. I have to understand it. And that means I need >>>>> information, >>>>> > > and details. I need more information. >>>>> > >>>>> > > > A rather simple approach >>>>> > > > may be to define a service layer (e.g. just a single static >>>>> class) >>>>> > > > that has a public API derived from use cases >>>>> > >>>>> > > "derived from use cases " - That's the first thing I've read that >>>>> > > makes sense. Thank you. >>>>> > >>>>> > > > and only in this layer >>>>> > > > ISession objects and a session factory is allowed. Then in each >>>>> public >>>>> > > > method a fresh session is opened, data fetched, maybe some kind >>>>> of >>>>> > > > post-processing/conversion/transformation is done, and before >>>>> > > > returning the result the session will be closed. This is the >>>>> basic >>>>> > > > idea of session per business transaction (or per use case). >>>>> > >>>>> > > > For applications that are not too complex this might suffice, in >>>>> more >>>>> > > > complex scenarios patterns like the mentioned persistence context >>>>> > > > might be needed. >>>>> > >>>>> > > > Hope, this helps a little bit. >>>>> > >>>>> > > A little bit. Thank you Stefan! >>>>> > >>>>> > > -Chris >>>>> >>>>> >>>> >>>> >>>> >>> >>> >>> -- >>> Fabio Maulo >>> >> >> >> >> -- >> Fabio Maulo >> >> >> > > > > -- Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
