Access child-collection through Interface on parent object (als interface) #2777
Replies: 3 comments 3 replies
-
Have you tried making the Documents and Addresses properties have the actual business object type? Or if you want to stick to interfaces, use one of the other higher-level interfaces provided with CSLA? |
Beta Was this translation helpful? Give feedback.
-
Do you have more than one class which implements |
Beta Was this translation helpful? Give feedback.
-
There are interfaces for each of the base classes in CSLA, specifically to support unit testing or maybe polymorphism. You can create your interface type as a subclass of the base interface type to get all the other interfaces necessary to act as a CSLA base type (warning: it is a lot). public interface IPersonEdit : Csla.IBusinessBase
{
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm in a project right now were we use the dataportal (webApi) and we use the regular csla objects there. The 'layer' where we actually use our CSLA objects is a .NET standard project so we rely heavily on interfaces. We now have an interface IPerson (used on the readonly and editable object) and IPersonEditable (for the editable object))
However, when the BusinessObject is a parent, the child-collections are not available, so when for instance Person would have a property DocumentCollection and AddressCollection these are (now) not available on IPersonEditable, I could add that like so
IEnumerable Documents
IEnumerable Addresses
on the IPersonEditable, but then you miss out on AddNew, Remove, Save, Clear, BeginEdit, IsDirty, IsSavable etc... methods wich are available on the collection objects.
it seems like a lot of work to create an IMyCollection interface or something with all that functionality mapped correctly and I was wondering if anyone has tried this already and might give me some pointers or a workaround or maybe some example code.
I was also thinking of maybe solving this (partly) through extensions methods but in those extension methods you would need access to the actual BusinessObject code directly, which would probably be a problem.
regards,
Jurjen.
Beta Was this translation helpful? Give feedback.
All reactions