Calling EqualityComparison with outer property
See original GitHub issueHi, Is scenario where EqualityComparison is not 1:1 between DTO <-> ENTITY in meaning entity needs to take some equality value from outer dto object? Entity itself identity has one column of parent and one own column. See class example.
Is there any way how to handle these ??? in EqualityComparison with given class structure?
CreateMap<InnerDto, InnerDb>().EqualityComparison((dto, o) => dto.Name== o.Name && dto.??? == o.OuterId);
class OuterDto {
public int Id { get; set; }
public List<InnerDto> InnerDtos { get; set; }
}
class InnerDto {
public string Name { get; set; }
}
class InnerDb {
public string Name { get; set; }
public int OuterId { get; set; }
}
THANKS FOR HELP.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
c# - Comparing two lists and ignoring a specific property
Your idea of using the IEqualityComparer is fine, it's your execution that is wrong. Notably, your GetHashCode method.
Read more >C# Design, many properties, complex constructor and ...
I am designing an object that will have 20 separate string properties, none of which are required. These constraints are fixed and cannot...
Read more >Equality comparisons and sameness - JavaScript | MDN
Same-value equality using Object.is() Internally, when an immutable property is redefined, the newly-specified value is compared against the ...
Read more >[JavaScript] - How to call an object within an object
When a function is defined inside another function, it can only be accessed or called from within the outer function. Here's an example...
Read more >Stackoverflow when setting up and calling object.Equals ...
Version Moq 4.10.1 .Net Framework 4.7.2 Description performing mocked.Equals(new object() throws a StackOverflowException.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
From you ‘InnerDto’ you need to have a property reference to the ‘OuterDto’ to be able to do the lookup. It does not exists any way in AM to find the parent object during the mapping without the reference what I know about. Without support in AM it’s hard to add support in AM.Collection.
Yes, the repo is active, it’s an open source project without paid members so no dedicated resources asdigned on this, all members are working on spare time with this.
I dont think it’s possible to do without modification.