Bug #49850 Entity Framework - Table per Type inheritance List error

Submitted: 21 Dec 2009 15:15 Modified: 24 Mar 2010 13:45
Reporter: Eduardo Lima Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:6.1.3 OS:Any
Assigned to: CPU Architecture:Any
Tags: entity framework, Inheritance

[21 Dec 2009 15:15] Eduardo Lima
Description:
There is a problem using table per type inheritance when listing the contents of the parent table.
For some reason the result of the query is a list of child objects, even if there is no related child record with the same parent Id.

How to repeat:
Create a simple application with 2 tables (parent and child) and replace the one-to-one foreign key relationship to a inheritance relationshiop. Then use the code above.
The first query returns correctly a list of all child objects, but the second query returns a list of all parent, but with the "is child" incorrectly set to true for all items in the list

using (testdbEntities ctx = new testdbEntities())
{
    IList<child> childs = ctx.parent.OfType<child>().ToList();
    foreach (child c in childs)
    {
        Console.WriteLine("name: " + c.nameParent + " desc: " + c.DescChild);
    }

    IList<parent> parents = ctx.parent.ToList();
    foreach (parent p in parents)
    {
        Console.WriteLine("name: " + p.nameParent + " is child: " + (p is child));
    }
}

Suggested fix:
I could fix this problem changing the MySql provider to a comercial product - called Devart dotConnect for MySQL.
[21 Dec 2009 15:35] Eduardo Lima
Test Case Project and Database creation script

Attachment: InheritanceTest.zip (application/x-zip-compressed, text), 33.73 KiB.

[3 Feb 2010 7:34] Tonci Grgin
Eduardo, your report is being discussed internally, we did not forget about it.
[11 Feb 2010 13:21] Tonci Grgin
Eduardo.

Your test case crashes in 
        public string DescChild
        {
            get
            {
                return this._DescChild;
            }
            set
            {
                this.OnDescChildChanging(value);
                this.ReportPropertyChanging("DescChild");
                this._DescChild = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
                this.ReportPropertyChanged("DescChild");
                this.OnDescChildChanged();
            }
        }

after executing IList<parent> parents = ctx.parent.ToList();

which makes it rather useless. Can you please rework your code so that it works against latest released version of c.NET (6.2.2)?
[8 Mar 2010 21:16] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/102619

799 Reggie Burnett	2010-03-08
      - fixed bug in sql generation when using a negated binary fragment in EF (bug #49850)
[8 Mar 2010 21:23] Reggie Burnett
fixed in 6.0.6, 6.1.4, 6.2.3, 6.3.2+
[9 Mar 2010 6:59] Tonci Grgin
Thanks Reggie.
[24 Mar 2010 13:45] Tony Bedford
An entry has been added to changelogs: 6.0.6, 6.1.4, 6.2.3, 6.3.2:

When using table per type inheritance and listing the contents of the parent table, the result of the query was a list of child objects, even though there was no related child record with the same parent Id.
[17 May 2011 15:06] Alexander Sidorov
Looks like this bug is reproducable again in 6.3.6
[17 May 2011 15:11] Alexander Sidorov
Looks like this bug is reproducable again in 6.3.6

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.044 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.