You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicclassFoo{privateBar_bar;publicvirtualMaybe<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.
@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.
@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.
Moved from discussions.
Question
From @alexmurari
Consider this:
Maybe<T>
type is commonly used in functional programming/DDD to make explicit whether or not an reference type is null (more or less likeNullable<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.
The text was updated successfully, but these errors were encountered: