Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query: invalid sql (variable has already been declared) for query with join where both sources contain reference to the same parameter #12871

Closed
maumar opened this issue Aug 2, 2018 · 1 comment

Comments

@maumar
Copy link
Contributor

maumar commented Aug 2, 2018

query:

                var local = new Customer
                {
                    CustomerID = "ANATR"
                };

                var query = (from c in ctx.Customers
                             where c == local
                             select c).Join(from c2 in ctx.Customers
                                            where c2 == local
                                            select c2, o => o, i => i, (o, i) => o).Select(e => e.CustomerID);

                var result = query.ToList();

sql:

SELECT [c].[CustomerID]
FROM [Customers] AS [c]
INNER JOIN (
    SELECT [c2].*
    FROM [Customers] AS [c2]
    WHERE [c2].[CustomerID] = @__local_0_CustomerID
) AS [t] ON [c].[CustomerID] = [t].[CustomerID]
WHERE [c].[CustomerID] = @__local_0_CustomerID

exception:

The variable name '@__local_0_CustomerID' has already been declared. Variable names must be unique within a query batch or stored procedure.

@smitpatel
Copy link
Contributor

Duplicate of #14645

@smitpatel smitpatel marked this as a duplicate of #14645 Jun 10, 2019
@smitpatel smitpatel removed this from the 3.0.0 milestone Jun 10, 2019
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants