Home

Problem with query after upgrade from 5.43.00 to 5.44.02

Hello all,

Has there been any report of Linq2SQL issues related to the version upgrade mentioned in the subject? A query (admittedly fairly heinous) that worked fine in 5.43.00 now fails in 5.44.02.

I won't provide the whole query yet because it is huge, but the error is:

SqlException: The column 'Id' was specified multiple times for 't25'.
The column 'Id' was specified multiple times for 't27'.

When looking at the SQL, we can see syntax errors like this in it:

[t25].[[id]]2]
[t25].[[id]]3]
[t25].[[id]]4]
etc.

Thanks in advance for any help.

Simon

Comments

  • Can you provide the DDL for t25?

  • Can you let me know how to do that (sorry for my ignorance)?

  • From SQL Server Management Studio, right-click the table and choose 'Script table as create'

  • Hi Joe. Sorry for the slow response, I was trying to simplify the problem right down because the DDLs for our tables are very large (plus t25 in this case was a sub-query table).

    The following query, using the two tables (both empty) shown in the comments at the top, works on 5.43.00 and fails on 5.44.02. Hopefully you can use it to recreate the problem yourself.

    Note the case difference on the "id" column in table Example 2.

    // SQL Used to create the two tables below. Note the *lower case* name of the id column in table Example2
    //
    //drop table if exists Example1;
    //drop table if exists Example2;
    //
    //create table Example1
    //(
    //  Id int,
    //  RelatedColumnExample1 nvarchar(10)
    //)
    //
    //create table Example2
    //(
    //  id int,
    //  RelatedColumnExample2 nvarchar(10)
    //)
    
    Example1s
    .Join(Example2s,
          e1 => e1.RelatedColumnExample1,
          e2 => e2.RelatedColumnExample2,
          (e1, e2) => new { e1, e2 })
    .GroupBy(j => new { j.e1, j.e2 })
    .Select(g => new { g.Key.e1, g.Key.e2 })
    .Where(x => x.e1.RelatedColumnExample1 == "ANY VALUE")
    

    Here is the resultant query:

    -- Region Parameters
    DECLARE @p0 NVarChar(1000) = 'ANY VALUE'
    -- EndRegion
    SELECT [t2].[Id], [t2].[RelatedColumnExample1], [t2].[id] AS [Id2], [t2].[RelatedColumnExample2]
    FROM (
        SELECT [t0].[Id], [t0].[RelatedColumnExample1], [t1].[id], [t1].[RelatedColumnExample2]
        FROM [Example1] AS [t0]
        INNER JOIN [Example2] AS [t1] ON [t0].[RelatedColumnExample1] = [t1].[RelatedColumnExample2]
        GROUP BY [t0].[Id], [t0].[RelatedColumnExample1], [t1].[id], [t1].[RelatedColumnExample2]
        ) AS [t2]
    WHERE [t2].[RelatedColumnExample1] = @p0
    

    If the case is made to match in the underlying SQL table, the query then works (I've included that query also, so the differences are clear):

    -- Region Parameters
    DECLARE @p0 NVarChar(1000) = 'ANY VALUE'
    -- EndRegion
    SELECT [t2].[Id], [t2].[RelatedColumnExample1], [t2].[Id2], [t2].[RelatedColumnExample2]
    FROM (
        SELECT [t0].[Id], [t0].[RelatedColumnExample1], [t1].[Id] AS [Id2], [t1].[RelatedColumnExample2]
        FROM [Example1] AS [t0]
        INNER JOIN [Example2] AS [t1] ON [t0].[RelatedColumnExample1] = [t1].[RelatedColumnExample2]
        GROUP BY [t0].[Id], [t0].[RelatedColumnExample1], [t1].[Id], [t1].[RelatedColumnExample2]
        ) AS [t2]
    WHERE [t2].[RelatedColumnExample1] = @p0
    
  • Joe, I should have dropped an extra note: the query in question that's failed is part of a critical business process. I'm not sure how easy a bug to fix this will be, but I'm worried it might be a problem and the next run of this process will be next week.

    If it turns out the bug is a problem to solve and given this query works in Linqpad version 5.43.00, would it be feasible for us to get access to a standalone copy of the older version? I've looked already but unfortunately there doesn't seem to be any means to access older versions of the app.

    Thanks again in advance,
    Simon

  • Thanks for the repro. Try the latest beta and let me know if it fixes your problem:
    https://www.linqpad.net/LINQPad5.aspx#beta

  • Many thanks Joe, that works! I imagine you already thought to try but to confirm: I did try the query in LinqPad 6 as well, which exhibited the same bug.

  • That's right: LINQPad 6 is affected as well. You'll see the fix in the next beta.

Sign In or Register to comment.