tags:

views:

178

answers:

2

I'm usign inheritance in linq2sql and have entites Supplier and Buyer that inherits from Client. I need to be able "upgrade" a Buyer to a Supplier.

I've tried:

        Client client = ClientMethods.ValidateId<Client>(clientId);
        client.ClientTypeId = ClientMethods.CLIENT_TYPE_SUPPLIER;
        db.SubmitChanges();

But get "Not allowed: Inheritance discriminator change from '1' to '2' would change type from 'Buyer' to 'Supplier'."

The only solution I can find is to do this without linq2sql and write a SP??

A: 

Perhaps, try to create a new supplier by populating the buyer's properties' value?

codemeit
If that's the only solution then I think I'll go for the SP.
Niels Bosma
+1  A: 

I am wondering why you even have the two different sub classes if it is a natural situation that you want to change from one type to the other. I think that you should refactor what you have and make the buyer and supplier one entity. Then if you have behavior that should be different based on whether or not the client is a buyer or supplier I would extract that into a seperate object which you can set or add to the client.

Caleb Vear