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

Combined Keys in Value-Objects #15962

Closed
1234Georg opened this issue Jun 5, 2019 · 4 comments
Closed

Combined Keys in Value-Objects #15962

1234Georg opened this issue Jun 5, 2019 · 4 comments

Comments

@1234Georg
Copy link

This is a follow up to #15884.

I am doing DDD, and I have a combinded key, that I want to model as a value-object. For a single key this will work with a Value-Converter or HasConversion.
But what about a combined key? A Value-Converter only works with a single value. Is there a way to make that in EF Core work?

Steps to reproduce

I made a sample project on github: https://github.com/1234Georg/EfCore30_CompositeKeyInValueObject

  • I have two Aggregates: ReportDiagram and Report
  • ReportDiagram has a combined key Quarter and Name.
  • There is no navigation property between these two, Reports reference ReportDiagram just by the key from ReportDiagram.
  • ReportDiagram references the Value-Object ReportDiagramId

This is the Value-Object for the combined key

    public class ReportDiagramId
    {
        public string Quarter { get; set; }
        public string Name { get; set; }
    }

Further technical details

EF Core version: 3.0.0-preview5.19227.1
Database Provider: Microsoft.EntityFrameworkCore.Sqlite, Version 3.0.0-preview5.19227.1
Operating system: Windows 10
IDE: Visual Studio 2019 16.0.3

@ajcvickers
Copy link
Contributor

Assuming that this should map to two columns in the database, then it looks like another scenario for #13947

@1234Georg
Copy link
Author

This is right, I should have found this by myself.

An additional note: When I query the ReportDiagram by its Id, the restriction should be evaluated in the database and not on the client. Otherwise it would load way to much data. The mapping of multiple columns in a conversion (#13947) would not help me then.

Do you plan to implement #13947 in 3.0?

@ajcvickers
Copy link
Contributor

@1234Georg You can tell if a feature is planned for the next release or not by looking at the milestone. #13947 is in the Backlog milestone, which means it's not planned for 3.0.

@1234Georg
Copy link
Author

@ajcvickers: Thanks for your time and patience.

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

2 participants