Quantcast
Channel: CSLA .NET
Viewing all articles
Browse latest Browse all 764

Using a derived business object in a generic class

$
0
0

So here is my setup. I have a class, CPData that derives from class PointData, that itself derives from BusinessBase<T>. I also have several other classes that derive from PointData,

I have a generic class, DataObjectCore<T> whose signature looks like this (I also have a member in that class of type BusinessBase<T>)

public class DataObjectCore<T> : where T : BusinessBase<T>

Now, in my class that uses DataObjectCore I am having problems. When I do this:

public class CPDataObject : DataObjectCore<CPData>

I get an error stating that the type CPData must be convertable to BusinessBase<CPData>. I understand what it's saying, but I am not sure of a way around it. If I change the type to be PointData it works, since that is the class that initially derived from BusinessBase. However I can't use PointData in this case. I have several other classes/business objects that pair up like CPData and CPDataObject.

This came about because we are converting our code from a custom in house business object framework to CSLA. Our in house solution didn't use generics so we are basically trying to minimize how much of our existing code gets changed. I do realize this isn't really specific to CSLA and it's more of an inheritance issue but I figured I'd star here first. Thanks!


Viewing all articles
Browse latest Browse all 764

Trending Articles