c# - Automapper ResolveUsing cause "Can't resolve this to Queryable Expression" -
i'm using autommaper map domain classes model classes , viceversa. need encrypt/decrypt 1 property. when map model domain there isn't problem, work perefectly:
mapper.createmap<entitymodel, entity>().formember(dest => dest.password, opt => opt.resolveusing(src => this.encryptstring(src.password)))
but when map entity model automapper crash , throws "can't resolve queryable expression":
mapper.createmap<entity, entitymodel>().formember(dest => dest.password, opt => opt.resolveusing(src => this.decryptstring(src.password)))
i've tried custom value resolver too, same result:
mapper.createmap<entity, entitymodel>().formember(dest => dest.password, op => op.resolveusing<passwordresolver>().frommember(x => x.password)); public class passwordresolver : valueresolver<object, string> { protected override string resolvecore(object source) { return "test"; } }
as documentation states, can't use custom resolvers in queryable expressions:
https://github.com/automapper/automapper/wiki/queryable-extensions#supported-mapping-options
you can, however, use mapfrom:
mapper.createmap<entity, entitymodel>() .formember(dest => dest.password, op => op.mapfrom(src => "test"));
i'm guessing that's not want password property that's how can fix example.
Comments
Post a Comment