CSLA with NHibernate

CSLA with NHibernate

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


jeusdi posted on Friday, September 28, 2007

Hello Forum,
    I'm interesting about using CSLA with NHibernate. I'm working with NHibernate 2 years ago and I need to add CSLA (N Undo, databinding, ...) features into my projects.

    My question is how or what's the best design in order to integrate NHibernate and CSLA.

           --> In MVC (Model-View-Controller) I would design "clear" classes into Model (Model contains NHibernate declarations...). So I would declare bussines objects in View (Model hasn't to know what's CSLA, I think) inheriting from Model classes (entities). For example:

                            public class EntityBO : Model.Entity { ...

            And in EntityBO, I would implement bussiness methods, ... In order to save or update these BOs I would implement a DAO pattern for each Model Entity class. For example, is I have a Project entity, I would implement a ProjectDAO with Save(Entity), Update(Entity), Delete(...), ... methods. When the user click on "Save" button I would perform --> ProjectDAO.Save(new EntityBO(....)).

What about this approach?

Thanks in advanced.

ajj3085 replied on Friday, September 28, 2007

I think NHibernate is typically used only in the DataPortal_XYZ methods.  You wouldn't expose any NHibernate to the UI, because you'd be letting your data schema into that layer, which is one of the things you're trying to avoid.

Dawn replied on Saturday, September 29, 2007

This has been discussed serval times, just search NHibernate in the forum.

And DavidDilworth had a ProjectTracker.NHibernate example solution on the CSLAcontrib site on CodePlex.

Copyright (c) Marimer LLC