I did read a thread that starting talking about a similar situation but it never really answered my question.
As per suggestions here and from Rocky, we have subclassed all of the base classes to create our own baseclasses that we inherit from. We have an Entity object that inherits from this and has child collections of addresses and contact numbers. We also have Classes for Customers, Employees and Vendors that inherit from Entity. One of the problems we encountered was in the child classes that are children of Entity. There are many places in the code where the parent is passed as a parameter but because we have declared the Entity class like this;
Partial Public MustInherit Class Entity(Of T As Entity(Of T))
Inherits
ACSBusinessBase(Of T)we receive errors about too few type arguments if we pass Entity as the parent class. I have read about possibly using interfaces in this situation but I am unsure of what is best. We use the CodesSmith generator tool and we are VBers in case you didn't already figure that one out.
Thanks in advance for any help you can offer.
Tom
The ACSBusinessBase is defined as:
<Serializable()> _
Public
MustInherit Class ACSBusinessBase(Of T As ACSBusinessBase(Of T))#
Region "Declarations" Inherits Csla.BusinessBase(Of ACSBusinessBase(Of T))#
End Region ' DeclarationsThe too few arguments error happens in many places such as
<NonSerialized()> _
Private executeInsertDelegate As predicateEx(Of SqlConnection, Entity) Private Function OnExecuteInsert(ByVal cn As SqlConnection, ByVal parent As Entity) As Boolean If Not executeInsertDelegate Is Nothing Then Return executeInsertDelegate(cn, parent) End If Return True End FunctionIt seems like the only way to get the error to go away is change Entity to Customer or Employee in these situations. That defeats the purpose though of having the the classes be children of Entity.
Thanks
Public MustInherit Class ACSBusinessBase(Of T As ACSBusinessBase(Of T), P As Entity(Of P))
'Where P is parent type
And then in your method you usePrivate Function OnExecuteInsert(ByVal cn As SqlConnection, ByVal parent As P) As Boolean
Although this is a workable solution, it might make it a pain in the ass to maintain. I'd say go with interfaces. There is probably a set of common properties that you'll want to access from the entity type, so if you make that an interface, you have no problems left...Thank you for your ideas. Is there a good interface example somewhere? It sounds like the best solution to use. I was reading one of Rocky's responses and his question was if the parent "acts-as" something different from itself then an interface was the best way. I'm just hoping to see and axample of it so I do it correctly.
Tom
Copyright (c) Marimer LLC