Bug #61714 ListView with EntityDataSource and DataPager throws NullReferenceException
Submitted: 30 Jun 2011 22:25 Modified: 29 Sep 2011 20:43
Reporter: Sho Ijiri Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.4.2rc OS:Microsoft Windows (Win7 + ASP.NET 4.0)
Assigned to: Fernando Gonzalez.Sanchez CPU Architecture:Any

[30 Jun 2011 22:25] Sho Ijiri
Description:

After upgrade MySQL Connector/net from 6.3.6 to 6.4.2rc, ListView with EntityDataSource
(using TypeFilter and Include EntityCollection Navigation Property) and DataPager causes
NullReferenceException at System.Web.UI.WebControls.EntityDataSourceView.ExecuteSelect.

This problem also occurs in 6.3.7 or later (incuding 6.4.x).

My enviroment is following:
- Windows 7 Ultimate 64bit (Japanese) SP1
- Visual Studio 2010
- .NET Framework 4.0
- MySQL 5.5.6rc
- MySQL Connector/NET 6.4.2rc

How to repeat:

* I'll send sample sourcecode later.

1. Create tables a, a2, and  b in database abcd.
   a:a2 = 1:0-1 relationship
   a:b  = 1:n   relationship

2. Start visual studio 2010, and create new ASP.net 4.0 website project.
3. Create edmx to App_Code/Model.edmx using wizard.
4. In edmx designer:
4-1. define a2 as inheritance of a
4-2. remove some properties which are duplicated with a from a2
5. Create new aspx page.
6. add EntityDataSource, DataPager, and ListView

        <asp:EntityDataSource ID="EntityDataSource1" runat="server" 
            ConnectionString="name=abcdEntities" DefaultContainerName="abcdEntities" 
            EnableDelete="True" EnableInsert="True" EnableUpdate="True" EntitySetName="a" 
            Include="b" EnableFlattening="False" EntityTypeFilter="a2">
        </asp:EntityDataSource>

        <asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1">
            <Fields>
                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                    ShowLastPageButton="True" />
            </Fields>
        </asp:DataPager>

        <asp:ListView ID="ListView1" runat="server" DataKeyNames="idA" 
            DataSourceID="EntityDataSource1">

              ...
        </asp:ListView>
    
7. Run
8. You'll get NullReferenceException error

without DataPager, Include="b", or entity object inheritance, this error doesn't occur.
[30 Jun 2011 22:26] Sho Ijiri
sample sourcecode

Attachment: test1.zip (application/x-zip-compressed, text), 140.02 KiB.

[4 Jul 2011 9:03] Bogdan Degtyariov
Hello Sho,

Thanks for the detailed description of the problem and for the test case.
It failed for me after adding DataPager as you said.
Setting the bug status to "verified".
[29 Sep 2011 20:43] Fernando Gonzalez.Sanchez
Thank you for your bug report. This issue has already been fixed in the latest released version of that product, which you can download at

  http://www.mysql.com/downloads/

This was fixed as part of the fix for http://bugs.mysql.com/bug.php?id=61729,
on releases 6.2.6, 6.3.8, 6.4.4.
[29 Feb 2012 21:08] John Russell
Added to changelog for 6.2.6, 6.3.8, 6.4.4: 

Using a combination of ListView, EntityDataSource with TypeFilter and
Include EntityCollection Navigation Property, and DataPager caused a
NullReferenceException error in the
System.Web.UI.WebControls.EntityDataSourceView.ExecuteSelect
function.