My 2 cents on new CSLA

Injecting NHibernate Repository into CSLA ObjectFactory is much easier than doing this in CSLA BO.

AutoMapper is very hard to use to pass data from NHibernate model to CSLA BO due to many flag setting in DataPortal methods.

Aggregate root pattern is missing from CSLA, processing child list is completely different in ORM world. CSLA is still following the table-BO one-to-one style.

CSLA sample app has demo code of using ORM like EF or Linq2Sql, but MODEL in those ORM is just used as data structure. It’s fair to keep CSLA BO business rich, but why use ORM for? Just to connect to database?

The way CSLA using WCF is weird, a real world SOA app should not have a contract with just CRUD operation defined in it.

Exception handling is different, while it definitely makes sense for UI/F5 developers, it drove my nuts when looking for exception when things don’t work, exception suppose to bubble up all the way, not hidden in control somewhere.

N-level undo is interesting. Again, who is using it?

Most wonderful features in CSLA:

  • Very rich and thoughtful UI controls, like cslaActionExtender, error provider and the usage of datasource on WinForms/WPF. Drag and drop, property setting, etc… I really miss it, especially when doing UI tasks.
  • Broad UI/OS support, even covers iOS with monoTouch on hand. Using it as a rich screen DTO in app isn’t a bad idea. For data access, stick with NHibernate.

My demo app of how to use CSLA with NHbernate. Value Object pattern is used to process child line item list, flag comparison when updating list is possible, but not worth if lint_item_id doesn’t matter.

Advertisements

7 thoughts on “My 2 cents on new CSLA

  1. What sort of issues did you have with AutoMapper? I am using it without a problem. I have a generic resolver that I use for each mapped pair. This alters BypassPropertyCheck etc. I was on the forum talking to Rocky about it and apparantly ICheckRules does the same as this so I may not need to manually set the private variable.

    public static IMappingExpression CslaDestination(this IMappingExpression mappingExpression)
    where TDestination : Csla.Core.BusinessBase, Csla.Extensions.IEditableBusinessObjectForMapping, Csla.Core.ICheckRules
    {

    mappingExpression
    .ForMember(dest => dest.BrokenRulesCollection, opt => opt.Ignore())
    .BeforeMap((s, d) =>
    {
    d.BypassPropertyChecksMappingStart();
    d.SuppressRuleChecking();
    })

    .AfterMap((s, d) =>
    {
    d.BypassPropertyChecksMappingFinish();
    d.ResumeRuleChecking();
    })
    ;

    return mappingExpression;
    }

  2. For those root level properties, automapper is OK, but I could not figure out how to map the IList to csla BusinessList.

  3. This is in my extension library, but apparantly you don’t need it.
    http://forums.lhotka.net/forums/p/10237/47997.aspx#47997
    You can just use ICheckRules.

    However for completeness
    public interface IEditableBusinessObjectForMapping
    {
    void BypassPropertyChecksMappingStart();
    void BypassPropertyChecksMappingFinish();
    }

    The following is in my derivitive of BusinessBase:

    #region Implementation of IEditableBusinessObjectForMapping

    [NonSerialized] private FieldInfo _field = typeof(Csla.Core.BusinessBase).GetField(“_bypassPropertyChecks”, BindingFlags.Instance | BindingFlags.NonPublic |
    BindingFlags.FlattenHierarchy);

    public void BypassPropertyChecksMappingStart()
    {
    _field.SetValue(this, true);
    }

    public void BypassPropertyChecksMappingFinish()
    {
    _field.SetValue(this, false);
    }

    #endregion

    Regards
    Kevin

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s