Reflexive association

Reflexive association

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


MBursill posted on Wednesday, November 05, 2008

I'm still just learning CSLA.NET so its possible I may have overlooked something.

I'm trying to setup a security model where I have roles that can inherit from other roles. In my database I use reflexive association. A ParentRole field of the Roles table is associated back to the ID field of the same table.

From my understanding, CSLA.NET has the IsChild property which should be set in the constructor, but what do I do when the object will sometimes be a root and sometimes be a child?

-Mike.

RockfordLhotka replied on Wednesday, November 05, 2008

An object that may be a root or child is called a Switchable object, and the concept is discussed briefly in (I think) chapter 7 of the 2005 book, or chapters 4-5 of the upcoming 2008 book.

Be aware however, that switchable objects nearly always indicate a flawed object model. A model that is data-centric instead of responsibility-driven.

So while CSLA supports the concept, I do so grudgingly and because quite a few people use CSLA to create data-centric objects and I want to make them happy. But if you do good behavioral design you probably won't ever create a switchable object.

One bit of good news for people who do build switchable objects, is that the child data portal concept added in version 3.5 really simplifies the creation of switchable objects.

Copyright (c) Marimer LLC