Giter Site home page Giter Site logo

Comments (10)

TylerCarlson1 avatar TylerCarlson1 commented on July 4, 2024

If you already have a working fix could you make a pull request for this?
And you have a failing test you can add it to Pull Request so that this issue gets checked on every build.

from automapper.collection.

rizi avatar rizi commented on July 4, 2024

Unfortunately it's not a fix for everyone. It's just something that's ok for now in our application. What I can do is add a failing test via pull request. What unit test runner do you use, I didn't find a Testclass or Testmethod ( or something similar) in your tests. Br

from automapper.collection.

Tasteful avatar Tasteful commented on July 4, 2024

When reading the code it looks like the equivalent expression always is found for the concrete type.

If we take this example of mapping

                    //collection type
                    cfg.CreateMap<OrderDomain, OrderEf>()
                        .EqualityComparison((oo, dto) => BaseEquals(oo, dto))
                        ;

                    cfg.CreateMap<MailOrderDomain, MailOrderEf>()
                        .IncludeBase<OrderDomain, OrderEf>()
                        ;

and try to find the IEquivalentComparer based on the MailOrderDomain -> MailOrderEf we will not get any hits back, even that the mapping is including a base-mapping that has the EqualityComparison-set.

If I remember correctly I got the same issue in my project and without investigate why it happen, I added the EqualityComparison on all sub-mappings and get it to work.

from automapper.collection.

rizi avatar rizi commented on July 4, 2024

@Tasteful can you try to fix the failing unit test in my uploaded solution? I already tried to put the .EqualityComparison() to all sub types and remove it from the base type but it never gets called for any subtype. br

from automapper.collection.

rizi avatar rizi commented on July 4, 2024

@Tasteful thx! But I dont know If IncludeBase is enough. What if someone uses .include<> instead of .IncludeBase<> because the mappins are created the other way round? Br

from automapper.collection.

Tasteful avatar Tasteful commented on July 4, 2024

@rizi I have never used the .Include<,>(), will the mapping in that case be something like the following?

cfg.CreateMap<OrderDomain, OrderEf>()
    .EqualityComparison((oo, dto) => BaseEquals(oo, dto))
    .Include<MailOrderDomain, MailOrderEf>()
    .Include<OnlineOrderDomain, OnlineOrderEf>()
    ;

cfg.CreateMap<OnlineOrderDomain, OnlineOrderEf>()
    .EqualityComparison((ood, ooe) => DerivedEquals(ood, ooe))
    ;

cfg.CreateMap<MailOrderDomain, MailOrderEf>()
    ;

instead of

cfg.CreateMap<OrderDomain, OrderEf>()
    .EqualityComparison((oo, dto) => BaseEquals(oo, dto))
    ;

cfg.CreateMap<OnlineOrderDomain, OnlineOrderEf>()
    .EqualityComparison((ood, ooe) => DerivedEquals(ood, ooe))
    .IncludeBase<OrderDomain, OrderEf>()
    ;

cfg.CreateMap<MailOrderDomain, MailOrderEf>()
    .IncludeBase<OrderDomain, OrderEf>()
    ;

from automapper.collection.

Tasteful avatar Tasteful commented on July 4, 2024

@rizi Can you try with the pre-release on myget (https://www.myget.org/feed/automapperdev/package/nuget/AutoMapper.Collection) to see if that is solving your issue?

from automapper.collection.

rizi avatar rizi commented on July 4, 2024

@Tasteful, regarding the mapping that's exactly how it would look like, see: http://docs.automapper.org/en/stable/Mapping-inheritance.html

I will try the pre release as soon as possible (hopefully in the next few days)
Best regards

from automapper.collection.

rizi avatar rizi commented on July 4, 2024

@Tasteful I tried the pre-release package from your myget feed and ITS WORKING FINE!
THX

from automapper.collection.

Tasteful avatar Tasteful commented on July 4, 2024

@jbogard You can close this one also, package is published on nuget.

from automapper.collection.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.