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

Navigation property with different backing field type #22728

Closed
ajcvickers opened this issue Sep 24, 2020 · 0 comments
Closed

Navigation property with different backing field type #22728

ajcvickers opened this issue Sep 24, 2020 · 0 comments
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported

Comments

@ajcvickers
Copy link
Contributor

Moved from discussions.

Question

From @alexmurari

Consider this:

public class Foo
{
    private Bar _bar;
    public virtual Maybe<Bar> Bar => _bar; // Has implict conversion.
}

Maybe<T> type is commonly used in functional programming/DDD to make explicit whether or not an reference type is null (more or less like Nullable<T>).

So, I know that EF Core 3.1 doesn't support this, will EF Core 5 support it? Actually, since the EF Core premise is to work directly with backing fields, this feature should come naturally (I think 😄)

Edit: when I say work, I mean lazy-loading support too.

Replies

From @ajcvickers

@alexmurari We could allow explicit conversions between backing field and property to be defined. However, EF Core still needs to understand the property if it is used in queries, etc., so it's not clear in which scenarios this would really help.


From @alexmurari

@ajcvickers Many courses related to functional programming teaches us to use structs (monads) like the Maybe/Option types in our domain entities to explicitly tell whether or not a reference type is null. Actually, Vladimir Khorikov in his Pluralsight course about EF Core and DDD hit this limitation where he needed to encapsulate the navigation properties in these structs, but EF Core didn't play nice with it.

This would allow us to follow some functional programming principles more closely.

I think this is a common use-case, maybe there's even an issue open requesting this feature.


From @ajcvickers

@alexmurari I filed #22504 to track this.

@ajcvickers ajcvickers added customer-reported closed-no-further-action The issue is closed and no further action is planned. labels Sep 25, 2020
@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
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported
Projects
None yet
Development

No branches or pull requests

1 participant