flatten - AutoMapper: Does the Recognize.Prefixes work also in flattening? -


here's problem have. our simplified source graph looks like:

public class model {     public string name { get; set; }     public foo foo { get; set; } }  public class foo {     public bar bar { get; set; } }  public class bar {     public string name { get; set; } } 

the destination flat type is:

public class viewmodel {     public string name { get; set; }     public string fooname { get; set; }   } 

everything working when define custom mapping rules:

cfg.createmap<model, viewmodel>()    .formember(vm => vm.fooname, opts => opts.mapfrom(m => m.foo.bar.name)); 

but there possibility without specifying custom mapping, maybe kind of recognizeprefixes method or so. (e.g. recognizeprefixes("bar") should work when source property barname. in our case there bar.name). have lot of properties want map , lot of .formember lines mapping definition huge , ugly.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -