question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueObject is not equivalent to a Castle.Proxies ValueObject

See original GitHub issue

I’m getting data from an external source that provides a set of type_codes. I have the type_codes as entities in a table. So I’m constructing an object with child objects that each map to the type_code table. In this case an Animal object mapping to Breeds, in which each breed has a breed code. As this is a fairly long list, I’m going var allBreeds = _context.Breeds.ToList() to get the list of Breeds. Breed has a BreedType ValueObject on it with properties Code and DisplayName. This ValueObject only uses Code for its EqualityComponent. So I form a BreedType ValueObject with the breed_code from the external source and then try to find the reference Breed from allBreeds as it has the entity Id for that breed in the database. The problem seems to be that each breedType is a Castle.Procies.BreedTypeProxy, rather than a straight BreedType, so when I go

var referenceBreed = allBreeds.SingleOrDefault(x => x.BreedType == constructedBreedType);

two ValueObjects with the same code are not equivalent. How can I make them equivalent, or should I be doing this a different way?

The reason for pulling all the breeds back is so that I’m not doing lots of calls back to the database.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
vkhorikovcommented, Aug 8, 2020

I see the issue now. The original implementation of VO was tailored toward NHibernate, where the ORM doesn’t create proxies on top of value objects. Pushed a fix, should be published soon as v2.11.5. Let me know if this fixes the issue.

0reactions
robertlarkinscommented, Aug 9, 2020

@vkhorikov Thanks for the quick update to the library, this appears to have fixed my issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can I assign a value to a Castle.Proxy object property via ...
I assume this is because the object dataSource is not really a TDataSource like the type specifies, but a Castle.Proxies.
Read more >
Inline Editing + EF Core Proxy? in UI for Blazor
I can't get inline editing to work when the item is an EF Core 2.2.6 proxy (lazy loading turned on), it throws an...
Read more >
Entity Base Class
When a class implements an interface it makes a promise about some functionality, but that's not enough. Two classes implementing the same ......
Read more >
Proxies using Records with a base class broken since .NET 6
The Castle Proxies project doesn't seem very active: no code check-ins since March, and limited response to several raised issues. The EF Core ......
Read more >
Error The model item passed into the dictionary is of type ' ...
The model item passed into the dictionary is of type 'Castle.Proxies.TwoColumnBlockProxy', but this dictionary requires a model item of type 'MTA_Episerver.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found