This PR fixes generation of InheritanceMappingAttribute when you have stronger hierarchy than just one child.
Example
Let's pretend we have such class hierarchy:
public class WithInheritance
{
public int Id { get; set; }
public string Discriminator { get; set; } = null!;
}
public class WithInheritanceA : WithInheritance { }
public class WithInheritanceA1 : WithInheritanceA { }
public class WithInheritanceA2 : WithInheritanceA { }
Then when you try to get all WithInheritanceA objects linq2db would create this query:
SELECT
t1."Id",
t1."Discriminator"
FROM
"WithInheritance" t1
WHERE
t1."Discriminator" = 'WithInheritanceA'
But that's wrong: inherited entities WithInheritanceA1 and WithInheritanceA2 also should be included in query.
(t1."Discriminator" = 'WithInheritanceA' OR
t1."Discriminator" = 'WithInheritanceA1' OR
t1."Discriminator" = 'WithInheritanceA2')
My PR fixes that problem by finding all relations between inherited types and then adding it to collection of mapping attributes.
Unit test also included, was tested on PgSql
Hello.
This PR fixes generation of
InheritanceMappingAttribute
when you have stronger hierarchy than just one child.Example
Let's pretend we have such class hierarchy:
Then when you try to get all
WithInheritanceA
objects linq2db would create this query:But that's wrong: inherited entities
WithInheritanceA1
andWithInheritanceA2
also should be included in query.My PR fixes that problem by finding all relations between inherited types and then adding it to collection of mapping attributes. Unit test also included, was tested on PgSql