abpframework / abp

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
https://abp.io
GNU Lesser General Public License v3.0
12.92k stars 3.44k forks source link

Can ValueObject equality be implemented with this code? #16019

Closed cangunaydin closed 1 year ago

cangunaydin commented 1 year ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe the problem.

Hello, I use lots of valueobject in my domain, so i was searching for an implementation that the equality operator == can be used instead ValueEquals(). I have seen the issue #1728. Probably that's why equality op is removed from valueobject class.

Describe the solution you'd like

So when i look at some examples from Vladimir Khorikov here https://github.com/vkhorikov/CSharpFunctionalExtensions/blob/master/CSharpFunctionalExtensions/ValueObject/ValueObject.cs, I think they overcome this problem by caching the hashcode and getting unproxied type. Can't we adapt this solution to abp valueobject?

Additional context

No response

maliming commented 1 year ago

hi

You can create a new value object base class and use it.

Custom the IsValueObjectPredicate to change its check predicate.