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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:21:04+00:00 2026-05-17T22:21:04+00:00

I’ve an application that has three layers: 1. data layer: exposes Entity Framework entities

  • 0

I’ve an application that has three layers:
1. data layer: exposes Entity Framework entities
2. business logic layer: queries the EF model, gets entities and should expose DTO (data transfer objects)
3. UI layer: queries BL, gets DTOs and view them.

Now I’ve an issue. Different part of my application needs the same DTO but with a little bit different fields. For simplicity suppose that one of my BL classes expose a DTO called Person that is needed with Name and Surname once and with Name and Date Of Birth in other place.

I’d like to hear from you what you think about my simple solution. I’ve come that is necessary for my UI to agree with BL on a “DTO contract” so that the two layers agree on classes. In my example I would:

a) create an abstract Person class. This class doesn’t have any method nor field
b) create a method in BL called GetPerson that accepts, as parameter, a Person class
c) define two or more classes that derive from Person (suppose PersonName and PersonDOB)
d) my UI calls GetPerson passing in the needed type (like GetPerson(typeof(PersonName)))
e) BL fills in the Person class

What you think about it? Is there any better solution? I think this is not so good buy nothings better comes to my mind.

Thanks a lot.
Marco

  • 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-05-17T22:21:05+00:00Added an answer on May 17, 2026 at 10:21 pm

    I have a similar architecture in my MVC2 app. What I did:

    1. BL returns a Person DTO that have Name, Surname and DoB (all those properties are a part of Person)

    2. My Views work with Models, so I create specific models for each view. I would therefore have 2 Person models, ie. one with Name and Surname, other with Name and DoB.

    The conversion between DTOs and models is done by a set of classes I call Adapters. In order to simplify code I use Automapper. This is a brilliant piece of code that will copy properties from your DTOs to Models by taking into account naming conventions and explicit configuration. Do take a look at is, as you might want to use it to populate DTOs from your EF classes.

    Summing up, I have a consistent BL without any smells (this ‘give me a subclass of this type’ business is a bit of smell to me), and my views are working with strongly-typed models that contain only relevant data.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I have some data like this: 1 2 3 4 5 9 2 6
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.