c# - Automapper from SOAP Web Service to View Model -


i want use automapper mapping soap web service response model used return result through web api.

mostly of attributes returned in object web service codes, want show in response of our api descriptions related codes.

for example:

the web service response list of:

<charge>     <type>abc</type>     <qualifier>3</qualifier>     <periodcode>004</periodcode>     <code>ste</code> </charge> <charge> ... </charge> 

which encapsulated in class this:

class charge {     string type { get; set; }     string qualifier { get; set; }     string periodcode { get; set; }     string code { get; set; }     decimal rate { get; set; } } 

our model is:

public class rcharge {     public string description { get; set; }     public bool? includedinrate { get; set; }     public decimal? amountvalue { get; set; }     public string period { get; set; } } 

i have stored in database information related codes , descriptions, codes have own description.

the problem how map code returned in web service, description. have code, , make call database in search of code , description, ok? guess constructusing executed every item in response, make query here result in bunch of requests db.

automapper.mapper.initialize(config => {     config         .createmap<charge, rcharge>()         .constructusing(s => rchargeconstructor.construct(s)); });  public class rchargeconstructor {     public static rcharge construct(resolutioncontext context) {         if (context == null || context.issourcevaluenull)             return null;          var src = (charge)context.sourcevalue;          return new rcharge() {             description = src.type, // want description db             includedinrate = src.qualifier == "3",             amountvalue = src.rate,             period = src.periodcode // want description db         };     } } 

is there approach doing kind of mapping?


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo