I've three entity types: A, B and C.
These are mapped to the same database table.
B and C inherit A.
There're three records in the database table which is mapped by A, B and C.
Whenever I remain B and C mapped in the confi开发者_StackOverflowguration file, I get each entity three times.
I've tried to remove mappings for B and C, and then, I get the whole number of entities: three.
Finally, I've profiled SQL Server and the query started from the application is translated into three SQL SELECT commands.
How can I avoid this? Or I want to know if it's possible to map N classes to the same table without meaning that trying to get an entity would end in retrieving it as many times as target table is mapped.
Thank you in advance.
You need to map the class hierarchy using an inheritance mapping strategy, not by mapping each concrete class individually. Since you already store all three types in one table you should use table-per-class mapping. See this and this.
精彩评论