AutoMapper / AutoMapper.Collection

AutoMapper support for updating existing collections by equivalency
MIT License
245 stars 59 forks source link

Are nested lists supported? #165

Closed ww2406 closed 2 years ago

ww2406 commented 2 years ago

Hello,

Not sure if I'm doing something wrong or if this shouldn't work as I'm hoping, but I've been tearing my hair out for hours now trying to figure out some way to work around this.

I have a complex EF Core entity structure, say like this:

class A {
  public int Id { get; set; }
  public List<B> ListB {get; set; }
}

class B {
  public int Id { get; set; }
  public string Prop1 {get; set;}
  public List<C> ListC {get; set;}
}

class C {
  public int Id {get; set;}
  public string Prop2 {get; set;}
  ...
}

I need to send an email to some users based on changes in A, including some associated changes in B and C. EF's built-in change tracking seems almost purpose-made, except, of course, that Automapper normally overwrites collections. So, I was excited to see this, but I'm finding that every C in ListC in B still has every property listed as modified, suggesting it is still being replaced rather than updated. Is this expected? Or are there any thoughts on what I may have configured incorrectly?