I am looking at an inheritance structure using generics, the following seems to be ok.
public abstract class ChemicalBase:Csla.BusinessBase<ChemicalBase>
public class Herbicide:ChemicalBase
I would like to try something like this:
public abstract class ChemicalBase<T>:Csla.BusinessBase<T>
public class Herbicide:ChemicalBase<Herbicide>
and get the following error when building the code:
The type 'T' must be convertible to 'Csla.BusinessBase<T>' in order to use it as parameter 'T'
in the generic type or method 'Csla.BusinessBase<T>'
Be careful with Generics. They are not polymorphic. I suggest you implement your top level Base classes as generics (see other threads for samples of this) but then derive concrete classes from them as in your first example. By inserting a layer between CSLA and your BOs (the top level Base classes I referrred to) you can tweak how you want Csla to work and yet not worry about updating the framework each time it is revised. Plus you can add functionality to your base classes and all your BOs will pick them up instantly.
You may want to implement an Interface if you want polymorphic behavior.
Joe
How do I implement an interface for the above example?
Thanks in advance,
Sashidhar Kokku
Copyright (c) Marimer LLC