vkhorikov / CSharpFunctionalExtensions

Functional extensions for C#
MIT License
2.38k stars 301 forks source link

Comparing ValueObjects, InMemory vs from DBContext #227

Open magarbikram opened 4 years ago

magarbikram commented 4 years ago

EF Core creates a proxy of value object and when comparing they won't be equal. For eg: Address shippingAddress = Address.From("City", "State");

//for instance it has same values in each properties //NOTE: ShippingAddress is marked virtual and lazy loading has been enabled Address orderShippingAddress = dbContext.Orders.GetById(123).ShippingAddress; Assert.Equal(shippingAddress, orderShippingAddress) ;// this will fail as orderShippingAddress is a proxy of Address class

Should we avoid marking it as virtual??

vkhorikov commented 4 years ago

What version are you using? This should be fixed in the latest one: https://github.com/vkhorikov/CSharpFunctionalExtensions/issues/224