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.

Calling EqualityComparison with outer property

See original GitHub issue

Hi, 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:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Tastefulcommented, Aug 13, 2020

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.

1reaction
Tastefulcommented, Aug 13, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

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