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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:22:16+00:00 2026-05-27T07:22:16+00:00

Product Entity object is passed to the View. I want to add some properties

  • 0

Product Entity object is passed to the View. I want to add some properties that mainly concerns only the View like

public string MiddleImage
{
   get
   {
      return "M" + this.ImageUrl;
   }
}

And now I can use this property in the View

<img src="<%=Model.MiddleImage%>" />

My question is where I should add this property, in the Product Entity object itself or it’s better to create another class that inherits from Product?

public class ProductWrapper : Product
{
    public string MiddleImage
    {
       get
       {
          return "M" + this.ImageUrl;               
       }
    }
}
  • 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-27T07:22:17+00:00Added an answer on May 27, 2026 at 7:22 am

    I would create a ProductViewModel class that holds the properties that only your view cares about which of course can include any newly formed UI properties such as your image url.

    Then save yourself some leg work and use AutoMapper in your controller to map those properties from the entity to the View Model.

    Assign the view model’s custom properties after the map.

    Your Product entity maps to your persistence store, your ProductViewModel maps to your User Interface – exactly the separation of concerns MVC is trying to achieve.

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

Sidebar

Related Questions

I have an object that has a char property: public class Product { public
I have 2 extension methods that convert a MongoDB document to an entity/object. public
Suppose I have public class Product: Entity { public IList<Item> Items { get; set;
@Entity @Table(name=Product_info) public class Product { private int ProductIndex; private int priority; private Date
I'd like to produce following behaviour: User in the browser saves some entity. After
Taking the following object model: public abstract class Entity { public Guid Id {
Why can't I get value of entity object product.getName() loaded by id session.load(product.class,1) after
I have an entity Product which has relationship category, which is optional, and use
In our system we have an entity Product , which might have various custom
I have a Product and Category entity in many-to-many association. I am trying to

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.