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: Optional dependents on sibling types sharing same columns #20334

Open
smitpatel opened this issue Mar 18, 2020 · 2 comments
Open

Query: Optional dependents on sibling types sharing same columns #20334

smitpatel opened this issue Mar 18, 2020 · 2 comments

Comments

@smitpatel
Copy link
Member

smitpatel commented Mar 18, 2020

    public class Third_One : Second
    {
        public OwnedType ThirdOwned { get; set; }
    }

    public class Third_Two : Second
    {
        public OwnedType Third_Two_Owned { get; set; }
    }
    [Owned]
    public class OwnedType
    {
        public string Value { get; set; }
    }
            modelBuilder.Entity<Third_One>().OwnsOne(e => e.ThirdOwned, b => b.Property(e => e.Value).HasColumnName("TValue"));
            modelBuilder.Entity<Third_Two>().OwnsOne(e => e.Third_Two_Owned, b => b.Property(e => e.Value).HasColumnName("TValue").HasColumnType("nvarchar(max)"));

db.Set<Second>().Select(e => new
                {
                    ((Third_One)e).ThirdOwned,
                    ((Third_Two)e).Third_Two_Owned,
                })

Here, when selecting data from server, we get values in same column. Which is not enough to identify which entity Type it is. We decided to create a conditional based on discriminator in such cases so we get Discriminator value of principal from database and only materialize correct entity for correct principal.

@AndriySvyryd
Copy link
Member

See #20332 (comment)

@smitpatel
Copy link
Member Author

When dependent owned type is sharing a column with owned type in base, then the column will have data even though dependent owned type is missing. One way to fix is to make sure dependent materialization conditions ignore shared columns. Another way to fix is this issue where we utilize parent's info to call into materialization.

Once this is fixed, we can enabled scenario described in #20343 too

smitpatel added a commit that referenced this issue Mar 19, 2020
- Also add at least one additional property in each owned type. If there no columns other than shared PK then it is required dependent.
- Add a property in owned type which would be sharing column for hierarchy. Currently disabled due to #20334

Resolves #20343
Resolves #20336
Finishes left over test work from #20345
smitpatel added a commit that referenced this issue Mar 19, 2020
- Also add at least one additional property in each owned type. If there no columns other than shared PK then it is required dependent.
- Add a property in owned type which would be sharing column for hierarchy. Currently disabled due to #20334

Resolves #20343
Resolves #20336
Finishes left over test work from #20345
smitpatel added a commit that referenced this issue Mar 20, 2020
- Also add at least one additional property in each owned type. If there no columns other than shared PK then it is required dependent.
- Add a property in owned type which would be sharing column for hierarchy. Currently disabled due to #20334

Resolves #20343
Resolves #20336
Finishes left over test work from #20345
smitpatel added a commit that referenced this issue Mar 20, 2020
- Also add at least one additional property in each owned type. If there no columns other than shared PK then it is required dependent.
- Add a property in owned type which would be sharing column for hierarchy. Currently disabled due to #20334

Resolves #20343
Resolves #20336
Finishes left over test work from #20345
smitpatel added a commit that referenced this issue Mar 20, 2020
- Also add at least one additional property in each owned type. If there no columns other than shared PK then it is required dependent.
- Add a property in owned type which would be sharing column for hierarchy. Currently disabled due to #20334

Resolves #20343
Resolves #20336
Finishes left over test work from #20345
@ajcvickers ajcvickers added this to the 5.0.0 milestone Mar 20, 2020
@ajcvickers ajcvickers modified the milestones: 5.0.0, Backlog Jun 9, 2020
@smitpatel smitpatel removed their assignment Aug 27, 2020
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