How i use Csla.net with NHibernate-part 1

How i use Csla.net with NHibernate-part 1

Old forum URL: forums.lhotka.net/forums/t/6670.aspx


mamboer posted on Wednesday, March 25, 2009

  A few weeks ago,i started from cslaptrackerfactory
rolling my own digs on using NHibernate with csla.net,i share u my experience,you give me your opinions.BTW:I'm not experted on both of Csla.net and NHibernate now(May be in the future:-).

  My intention is clear:
  To implement csla's objectfactory,using NHibernate to do the data access job but decouple it from csla.net. Since we may use other DA technologies.

  The most important thing here is how to provide data to our Csla.net business objects.We have tow choices:
  1,Use independent DTO(a.k.a POCO)
  In this case,the relationship among BO,DTO and NHibernate will be "BO<->DTO<->Persistence with NH".If you wanna use NH's lazy load,you can take this option,since we couldn't make all of BO's public properties and methods virtual.
  2,Use Csla.NET BO as DTO
  The relationship becomes "BO<->NH",NHibernate will feed your BO directly.

  As Rocky had said somewhere,both of two options have their pros and cons,you should make your own choice.
  In order to fulfil these two options,i define my own custom business base class which like:
  http://sites.google.com/site/dafenbei/mamboernet/bobase
  http://sites.google.com/site/dafenbei/mamboernet/bobasefactory

  I define some methods on the BO base,if you use the DTO style,the factory class will use these methods to synchronize data between BO and DTO,NHibernate will do the persistence job after the synchronization.
  If you use the BO itself as DTO,things will be same as in the cslaptrackerfactory
  Now,let's say we use DTO style,the BO derived from my business base will look like,
  http://sites.google.com/site/dafenbei/mamboernet/bosample
 
  I am not sure whether i am on the right way,you can give me some of your opinions.Thanks so much.
 

Copyright (c) Marimer LLC