I am using ValueInjecter to map properties from a domain model to a DTO serviced through a service level. The service in question also receives updates ... therefore, the updated DTO is transmitted, and then it is entered into the domain object and saved.
// Domain public class Member { public Country Country { get; set; } } public class Country { public string Code { get; set; } public string Name { get; set; } } //Dto public class MemberDto { public string CountryCode { get; set; } } //Transformation Method attempt 1 public Member InjectFromDto (MemberDto dto, Member source) { source = source.InjectFrom<UnflatLoopValueInjection>(dto); return source; }
Now all of the above code updates Property Member.Country.Code, which is clearly not what I need for this.
So, from the docs, I decided that I needed to create an override and get the following:
public class CountryLookup: UnflatLoopValueInjection<string, Country> { protected override Country SetValue(string sourcePropertyValue) { return countryService.LookupCode(sourcePropertyValue); } }
My problem is during debugging, CountryLookup is never called.
Possible reasons I can think of:
- Nhibernate proxy classes that inject values do not match country type? This does not make sense, because it works during flattening.
- Perhaps for some reason unflattening does not shoot. Ie Dto - CountryCode and Domain - Country.Code
I need to use the CountryCode property on Dto to call countryService.LookupCode to return the correct object to use during the update.
nhibernate valueinjecter dto automapping
Galen
source share