This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, We are finding the primary key naming a little confusing in Class Table Inheritance. So, we'd like to change it. But it is not respecting the IdentityColumnName property. No matter what we put in there, it still calls the columns ID , in both LS 4 and the latest LS 5 nightly build. Option 1: What we'd really like, naming like this: Base class: Class Name: Animal Primary key name: Id (as normal) Derived classes: Class Name: Dog Primary key name: AnimalId (makes the link to Animal obvious) Class Name: Cat Primary key name: AnimalId Option 2: If the above is not possible, then a second choice would be to call it AnimalId everywhere, including the base class. Are either of the above options achievable now? If not, might either become achievable in the final release of LS 5? Thanks, John |
|
|
I might be missing something here, but this should work currently. e.g. Here is a quick version of your model I have defined. I have set IdentityColumnName to be AnimalId on Cat and Dog. It has the default of Id for Animal. Here is the SQL emitted for UnitOfWork.Cats.ToList() which reflects that setup correctly:
What am I missing?
|
|
|
Good point. I tried it again in our app, and it worked ... almost. The only problems was when doing a deletion. Say we were deleting a Cat entity. It was generating SQL like this: Delete Animal where AnimalId = x I.e. the column name in the where clause was the ID column name for the derived type, even for the SQL that deleted from the base table. (I have not tried this in your simple attached example, sorry, since I don't have time today. I presume the same defect would be reproducable there). As for my earlier problems, there must have been an error in my testing yesterday. |
|