Casting from a Inherited Class

Posts   
 
    
Daniel9 avatar
Daniel9
User
Posts: 19
Joined: 05-Apr-2005
# Posted on: 22-Jun-2005 01:41:53   

Hi Frans,

I'm trying to something which seems like it should be quite simple. I'm using the adapter method, i have a project called MyBusinessObjects which contains a number of classes that inherit from the generated entity objects, which i'll put any custom code i need to. For example MyCustomerEntity will inherit from CustomerEntity.

The problem i'm having is when saving this and related classes using SaveEntity and SaveEntityCollection.

The SaveEntity(myCustomerEntity) and SaveEntityCollection(myCustomerEntity.Orders) are both giving me errors.

If i create a new CustomerEntity

CustomerEntity ce = new CustomerEntity(myCustomerEntity.Fields)

And pass that it it will save but then i don't have access to the related EntityCollection MyCustomerEntity.Orders which also needs to be saved.

Is there any way to cast the derived classes so that i can pass them into the save methods? Or am i going about this the wrong way?

Thanks,

Daniel

EDIT: Sorry Frans the cast wasn't the issue here. The error was related to a date field that was being set to null but is being assigned the Min DateTime Value. Sorry again.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 22-Jun-2005 09:34:50   

Glad it's solved! simple_smile

Frans Bouma | Lead developer LLBLGen Pro