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 8389703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:47:56+00:00 2026-06-09T18:47:56+00:00

I have three entity. public class Book { public string Name {get;set;} } public

  • 0

I have three entity.

public class Book
{
    public string Name {get;set;}
}
public class Author
{
    public string AuthorName {get;set;}
}

public class BookDTO
{
    public string Name {get;set;}
    public string AuthorName {get;set;}
}

how to map Book and Author to BookDTO ?
and how to map BookDTO to Book and Author?
I used the automapper in my solution.

  • 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-09T18:47:57+00:00Added an answer on June 9, 2026 at 6:47 pm

    You could create a mapping for each:

    Mapper.CreateMap<Book, BookDTO>();
    Mapper.CreateMap<Author, BookDTO>();
    

    And then use it like this:

    Book b = new Book { Name = "Gulliver's Travels" };
    Author a = new Author { AuthorName = "Jonathan Swift" };
    
    var dto = Mapper.Map<Book, BookDTO>(b);
    
    Mapper.Map<Author, BookDTO>(a, dto);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Post entity: public class Post { public string Id {get;set;}
I have an entity like this: public class Person { public string Name {
I have an Entity like this: public class Category { public int classid {get;set;}
I have entity called Customer and it has three properties: public class Customer {
I have the following entity class : @Entity @Table(name = THE_TREE, catalog = ,
I have an example class book : public class Book { [Key] public int
I have a problem with JPA 1.0 (OpenJPA) Following situation @Entity public class A{
I have three classes: public partial class Student : Contact { //Inherited from Contact:
I have this simple situation: @Entity public class Customer{ @ManyToMany(fetch=FetchType.EAGER) @Cascade(CascadeType.SAVE_UPDATE) private List<Product> products=new
I have a similar situation like this one @Entity @Indexed public class Place {

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.