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

ArgumentException using same query source for multiple separate queries #6209

Closed
flipchart opened this issue Jul 30, 2016 · 3 comments
Closed
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@flipchart
Copy link

Steps to reproduce

Repro gist: https://gist.github.com/flipchart/a0983761f04077381acdfad1965fb6a6

The issue

System.ArgumentException: An item with the same key has already been added. Key: join WorkflowRecord _ in {from WorkflowRecord x in value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[Rublock.Data.DataModel.Workflows.WorkflowRecord]) join WorkflowRecord x.Parent in value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[Rublock.Data.DataModel.Workflows.WorkflowRecord]) on IIF(([x] != null), Property([x], "ParentId"), null) equals Convert(Property([x.Parent], "Id")) into IEnumerable`1 x.Parent_group from WorkflowRecord x.Parent in {[x.Parent_group] => DefaultIfEmpty()} join AccountRecord x.Owner in value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[Rublock.Data.DataModel.Accounts.AccountRecord]) on IIF(([x] != null), Property([x], "OwnerId"), null) equals Convert(Property([x.Owner], "Id")) into IEnumerable`1 x.Owner_group from AccountRecord x.Owner in {[x.Owner_group] => DefaultIfEmpty()} where (((IIF(([x.Owner] != null), [x.Owner].Username, null) == __query_Username_0) AndAlso (IIF(([x.Parent] != null), Convert([x.Parent].Id), null) == Convert(__query_WorkflowId_1))) AndAlso ([x].Id == __query_StepId_2)) select [x]} on [x].WorkflowServiceId equals {from WorkflowServiceRecord subQuery in value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[Rublock.Data.DataModel.Services.WorkflowServiceRecord]) where (Convert(Property([subQuery], "Id")) == Property([_], "ServiceId")) select [subQuery].Id => FirstOrDefault()}
   at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(Object key)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.RegisterSubQueryVisitor(IQuerySource querySource, RelationalQueryModelVisitor queryModelVisitor)

Further technical details

EF Core version: 1.0.0
Operating system: Windows 10
Visual Studio version: VS2015 14.0.25424.00 Update 3

@maumar maumar self-assigned this Aug 2, 2016
@maumar
Copy link
Contributor

maumar commented Aug 2, 2016

verified that this is a legitimate bug

@divega divega added this to the 1.1.0 milestone Aug 2, 2016
@maumar maumar modified the milestones: 1.1.0, 1.1.0-preview1 Oct 5, 2016
@maumar
Copy link
Contributor

maumar commented Oct 5, 2016

We think this is fixed now.

@maumar
Copy link
Contributor

maumar commented Oct 6, 2016

This is indeed fixed in the current bits. Currently we produce the following query:

SELECT [x].[FingerId]
FROM [PersonDefinitionFingerRecord] AS [x]
INNER JOIN (
    SELECT [x1].*
    FROM [PersonRecord] AS [x1]
    WHERE [x1].[Name] = N'Foo'
) AS [t] ON [x].[PersonDefinitionId] = (
    SELECT TOP(1) [subQuery0].[Id]
    FROM [PersonDefinitionRecord] AS [subQuery0]
    WHERE [subQuery0].[Id] = [t].[PersonDefinitionId]
)
WHERE [x].[Discriminator] = N'PersonDefinitionLeftFingerRecord'

@maumar maumar closed this as completed Oct 6, 2016
@maumar maumar added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed type-investigation labels Oct 6, 2016
@rowanmiller rowanmiller modified the milestones: 1.1.0, 1.1.0-preview1 Oct 12, 2016
@ajcvickers ajcvickers modified the milestones: 1.1.0-preview1, 1.1.0 Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

5 participants