I've quoted your original posting. It's completely my fault, I should have read your original posting better, then it would have been solved much earlier. Sorry for that.
wojt wrote:
Hi,
Is there any way to determine the subtype from a supertype entity without using a discriminator column?
For example, the supertype is Client. There are two types of clients, both subtypes of the Client entity - Individual and Organisation.
If I use the following code...
ClientEntity _client = new ClientEntity(clientId);
...I would like to be able to determine whether the client is an individual or an organisation. Any easy way of doing this?
Now, your code snippet has an explicit new ClientEntity() statement. This means that .NET will create a ClientEntity object. No matter what the type is of the entity identified by clientId, the object will be of type ClientEntity, due to the new operator.
To get a polymorphic fetch, and to get an instance of the type represented by the value clientId, you should do:
ClientEntity _client = ClientEntity.FetchPolymorphic(null, clientId, null);
LLBLGen Pro will then create an instance of the entity type represented by clientId and will return that. _client can then be of a different type. This works because ClientEntity is a supertype of the subtypes which can be produced. 'is' then works.