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: add support for projecting primitive collections from JSON entities #31364

Closed
maumar opened this issue Jul 27, 2023 · 1 comment
Closed
Assignees
Labels
area-json area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Milestone

Comments

@maumar
Copy link
Contributor

maumar commented Jul 27, 2023

Currently there is an issue when projecting collection of primitives from JSON entities (specifically, nested ones) - problem is in shared type expanding visitor - we don't correctly handle includes that the JSON type gets expanded to - in case of other navigations we can successfully bind them, in case of primitive non-collections we just ignore them (the includes), but in case of collection of primitives we leave them as they are but fail to reason about them correctly in the translation phase.

example

ss.Set<JsonEntityBasic>()
                .OrderBy(x => x.Id)
                .Select(x => x.OwnedCollectionRoot
                    .Where(xx => xx.Name == "Foo")
                    .Select(xx => new { xx.Names, xx.Numbers })
                    .ToList())

throws:

 Translation of 'EF.Property<string[]>(IncludeExpression(
    EntityExpression:
    IncludeExpression(
        EntityExpression:
        EntityShaperExpression: 
            TestModels.JsonQuery.JsonEntityBasic.OwnedCollectionRoot#JsonOwnedRoot
            ValueBufferExpression: 
                ProjectionBindingExpression: EmptyProjectionMember
            IsNullable: False
        , 
        NavigationExpression:
        MaterializeCollectionNavigation(
            Navigation: JsonEntityBasic.OwnedCollectionRoot#JsonOwnedRoot.OwnedCollectionBranch,
            subquery: o.OwnedCollectionBranch Q-> 
                .AsQueryable()
                .Select(o0 => IncludeExpression(
                    EntityExpression:
                    IncludeExpression(
                        EntityExpression:
                        o0, 
                        NavigationExpression:
                        MaterializeCollectionNavigation(
                            Navigation: JsonEntityBasic.OwnedCollectionRoot#JsonOwnedRoot.OwnedCollectionBranch#JsonOwnedBranch.OwnedCollectionLeaf,
                            subquery: EF.Property<List<JsonOwnedLeaf>>(o0, "OwnedCollectionLeaf")
                                .AsQueryable()), OwnedCollectionLeaf)
                    , 
                    NavigationExpression:
                    EF.Property<JsonOwnedLeaf>(o0, "OwnedReferenceLeaf"), OwnedReferenceLeaf)
                )), OwnedCollectionBranch)
    , 
    NavigationExpression:
    IncludeExpression(
        EntityExpression:
        IncludeExpression(
            EntityExpression:
            EntityShaperExpression: 
                TestModels.JsonQuery.JsonEntityBasic.OwnedCollectionRoot#JsonOwnedRoot.OwnedReferenceBranch#JsonOwnedBranch
                ValueBufferExpression: 
                    o.OwnedReferenceBranch Q-> 
                IsNullable: True
            , 
            NavigationExpression:
            MaterializeCollectionNavigation(
                Navigation: JsonEntityBasic.OwnedCollectionRoot#JsonOwnedRoot.OwnedReferenceBranch#JsonOwnedBranch.OwnedCollectionLeaf,
                subquery: o.OwnedReferenceBranch Q-> OwnedCollectionLeaf
                    .AsQueryable()), OwnedCollectionLeaf)
        , 
        NavigationExpression:
        EntityShaperExpression: 
            TestModels.JsonQuery.JsonEntityBasic.OwnedCollectionRoot#JsonOwnedRoot.OwnedReferenceBranch#JsonOwnedBranch.OwnedReferenceLeaf#JsonOwnedLeaf
            ValueBufferExpression: 
                o.OwnedReferenceBranch Q-> OwnedReferenceLeaf
            IsNullable: True
        , OwnedReferenceLeaf)
    , OwnedReferenceBranch)
, "Names")' failed. Either the query source is not an entity type, or the specified property does not exist on the entity type.
@maumar
Copy link
Contributor Author

maumar commented Aug 2, 2023

fixed as part of #31369

@maumar maumar closed this as completed Aug 2, 2023
@maumar maumar added this to the 8.0.0 milestone Aug 2, 2023
@maumar maumar self-assigned this Aug 2, 2023
@maumar maumar added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Aug 2, 2023
@ajcvickers ajcvickers modified the milestones: 8.0.0, 8.0.0-rc1 Aug 19, 2023
@ajcvickers ajcvickers modified the milestones: 8.0.0-rc1, 8.0.0 Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-json area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Projects
None yet
Development

No branches or pull requests

2 participants