This question is locked. New answers and comments are not allowed.
Hi,
let's take a simple example mapped with flat inheritance:
public
abstract
class
Animal
{
public
int
Id {
get
;
set
; }
public
string
Name {
get
;
set
; }
public
Home Home {
get
;
set
; }
}
public
class
Dog : Animal
{
public
int
Age {
get
;
set
; }
}
public
class
Cat : Animal
{
public
int
Lives {
get
;
set
; }
}
public
class
Home
{
public
int
Id {
get
;
set
; }
public
string
Name {
get
;
set
; }
public
Home() { Animals =
new
List<Animal>(); }
public
IList<Animal> Animals {
get
;
set
; }
}
For accessing the property home.Animals the generated SQL statement would be:
SELECT
b.[Id] COL1, b.[voa_class] COL2, b.[HomeId] COL3, b.[nme] COL4, b.[Lives] COL5, b.[Age] COL6
FROM
[Home] a
LEFT
JOIN
[Animal]
AS
b
ON
(a.[Id] = b.[HomeId]
AND
(b.[voa_class]
IN
(
'Animal'
,
'Dog'
,
'Cat'
)))
WHERE
a.[Id] = @p0
Here is something I don't understand. Why is the 'Animal' appearing in the JOIN clause?
The Animal class is abstract which means there will never be any objects of that type. Indeed in the table there are no other entries but 'Dog' and'Cat'.
I think the ORM should optimize the statement by removing the abstract types from the JOIN clauses.