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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:13:32+00:00 2026-05-23T22:13:32+00:00

Situation: I have a large shrink wrapped application that my company bought. It is

  • 0

Situation: I have a large shrink wrapped application that my company bought. It is supposed to be extensible, yada, yada. It has a DB, DAL and BLL in the form of SQL and DLLs. It also has a MVC project (the extensible part) but 95% of the “Model” part is in the DAL/BLL libraries.

Problem: I need to extend one of the “Models” located in the BLL. It is an User object with 47 properties, 0 methods and no constructor. What I started was a simple deivation of their class like:

public class ExtendedUser : BLL.DTO.User
{
    public bool IsSeller { get; set; }
    public bool IsAdmin { get; set; }
}

This works fine if I just create a new ExtendedUser. However, it is populated by another call into their BLL like:

BLL.DTO.User targetUser = UserClient.GetUserByID(User.Identity.Name, id);

I tried the straight forward brute force attempt, which of course throws a Cast Exception:

ExtendedUser targetUser = (ExtendedUser)UserClient.GetUserByID(User.Identity.Name, id);

I am drawing a complete blank on this very simple OO concept. I don’t want to write a Constructor that accepts the existing User object then copies each of the properties into my extended object. I know there is a right way to do this. Can someone slap me upside the head and tell me the obvious?

TIA

  • 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-23T22:13:34+00:00Added an answer on May 23, 2026 at 10:13 pm

    If you do want to use inheritance, then with 47 properties, something like Automapper might help you copy all the values across – http://automapper.codeplex.com/ – this would allow you to use:

    // setup
    Mapper.CreateMap<BLL.DTO.User, ExtendedUser>();
    
    // use
    ExtendedUser extended = Mapper.Map<BLL.DTO.User, ExtendedUser>(user);
    

    Alternatively, you might be better off using aggregation instead of inheritance – e.g.

    public class AggregatedUser
    {
        public bool IsSeller { get; set; }
        public bool IsAdmin { get; set; }
        public BLL.DTO.User User { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly large CRUD WinForm app that has numerous objects. Person, Enrollment,
I have a large Ruby on Rails form that has the following partial view
I am working on a project that has the potential to have a large
I have situation where a user can manipulate a large set of data (presented
I have a very strange situation. I have a large set of records to
Pseudo-situation: have a class (let's say BackgroundMagic ), and it has Start() and Stop()
Situation I have a client library that uses the Windows Azure AppFabric Service Bus
I have a project that has a fairly complicated, nested (references calling the referenced
I have a situation with a relatively large git repository located in a virtual
I have a situation where there is a small piece of Java code that

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.