Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9242047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:29:56+00:00 2026-06-18T08:29:56+00:00

i’m sorry i’m newbie to enterprise application as well as the design pattern. might

  • 0

i’m sorry i’m newbie to enterprise application as well as the design pattern. might be this question occcur lack of knowledge about design pattern. i found that its better to use DTO to transfer data.

my business entity class as below:

public class Patient
{    
    public string ID { get; set; }
    public string FullName { get; set; }
    public string FirstName { get; set; }
    public string Surname { get; set; }
}

so in my application user only give ID and HospitalID. so it calls for another web service and get person information

 public class PersonDTO
 {
     public string NIC { get; set; }
     public string FullName { get; set; }
     public string FirstName { get; set; }
     public string BirthPlace { get; set; }
     public string BirthCertificateID { get; set; }
 }

so based on these information im going to Patient object. (Using DTO pattern)

so i thought of write new class to convert this as follows.

public class PatientDO
{
    public static Patient ConvertToEntity(
        PatientRegistrationDTO pregDTO,
        PersonDTO person
    )
    {
        Patient p = new Patient();
        p.NIC = pregDTO.NIC;
        p.FullName = person.FullName;
        p.FirstName = person.FirstName;
        return p;
    }
}

but lately i read few articles and they used Serializer Helper class as well as the XmlSerializer i can’t understand why they used somthing like that.

for the DTO pattern is that need to use XmlSerializer and why it is used?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:29:57+00:00Added an answer on June 18, 2026 at 8:29 am

    You should really take a look at AutoMapper.

    http://automapper.org

    This is a piece of software that you can include in your solution that will automatically map values from one class to another.

    It’ll map properties with the same name automatically, and is also pretty smart when it comes to child objects. However, it also offers complete mapping control when you need it.

    EDIT

    Couple of examples to show how AutoMapper works. Please note I’d never code like this in real life. Brevity!

    Example classes.

    // Common scenario.  Entity classes that have a connection to the DB.
    namespace Entities 
    {
       public class Manager
       {
          public virtual int Id { get; set; }
          public virtual User User { get; set; }
          public virtual IList<User> Serfs { get; set; }
       }
    
       public class User
       {
          public virtual int Id { get; set; }
          public virtual string Firstname { get; set; }
          public virtual string Lastname { get; set; }
       }
    }
    
    
    
    // Model class - bit more flattened
    namespace Models 
    {
       public class Manager 
       {
          public int Id { get; set; }
          public string UserFirstname { get; set; }
          public string UserLastname { get; set; }
          public string UserMiddlename { get; set; }
       }
    }
    

    Typically, you’d have a part of your project to configure all your AutoMapping. With the examples I’ve just given, you can configure a map between Entities.Manager and Models.Manager like so:-

    // Tell AutoMapper that this conversion is possible
    Mapper.CreateMap<Entities.Manager, Models.Manager>();
    

    Then, in your code, you’d use something like this to get a new Models.Manager object from the Entity version.

    // Map the class
    var mgr = Map<Entities.Manager, Models.Manager>
      ( repoManager, new Models.Manager() );
    

    Incidentally, AM is smart enough to resolve a lot of properties automatically if you name things consistently.

    Example above, UserFirstname and UserLastname should be automatically populated because:-

    • Manager has a property called User
    • User has properties called Firstname and Lastname

    However, the UserMiddlename property in Models.Manager will always be blank after a mapping op between Entities.Manager and Models.Manager, because User does not have a public property called Middlename.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't have much knowledge about the IPv6 protocol, so sorry if the question
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I know there's a lot of other questions out there that deal with this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.