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

  • Home
  • SEARCH
  • 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 9215003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:06:14+00:00 2026-06-18T02:06:14+00:00

How would you implement a model with dynamic properties with using mvc/razor? I really

  • 0

How would you implement a model with “dynamic properties” with using mvc/razor? I really am not sure if “dynamic properties” is the correct term.

Scenario: I have a list of items from the DB. Each of these items are then given a set of “properties” from a list of attributes (also from the DB).

In my Item model I think I should have a collection of attributes/properties, correct? Something like

public class Item
{

    public int ItemId { get; set; }
    public string ItemName{ get; set; }

    public virtual ICollection<Attribute> Attributes { get; set; }
}

public class Attribute
{
    public int AttributeId { get; set; }
    public string AttributeName { get; set; }
}

My goal is to render a view such that if a user selects an item from a dropdownlist, the set of properties associated with the selected item will be shown with the corresponding html input elements (either textbox or dropdownlist).

Example UI when a user selects an item from a dropdownlist (let’s say it is a “Camera”)

  • Camera
    • Brand – [textbox]
    • Model – [textbox]
    • Warranty – [dropdownlist of warranty length]

Example UI when a user selects an item from a dropdownlist (let’s say it is a “House”)

  • House
    • Floor Area – [textbox]
    • Number of Rooms – [textbox]
    • Number of Rooms – [textbox]

Creating/Editing/Deleting a straightforward model like the Attribute defined above is no problem. What’s throwing me off is the way to implement the “dynamic properties” described above.

I’m coming from WebForms and still quite new to MVC so take it easy on me ok? 🙂

  • 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-18T02:06:15+00:00Added an answer on June 18, 2026 at 2:06 am

    As it turns out, this can easily be done just like any other model implementation. I just had to create “Item Templates” which contains the attributes and other meta-data related to the item’s attribute. Then I ask the user to pick a “template” so that I can update the list of attributes and the view accordingly. After that, the user can now fill out the corresponding values for each of the attributes in the template. The resulting model is a different model from the item template so there were partial views and editor templates involved.

    I know this is not related to the question but I guess it’s worth mentioning that using View Models instead of the Domain Model eases things up. A lot.

    Another thing that I had to do to make things a bit easier was to use a document-oriented storage instead of the traditional relational database as I think EAV-type of projects like this are more suited for NoSQL.

    The next problem that I faced was how to validate the user’s input based on the data type of the attribute here.

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

Sidebar

Related Questions

I have a calendar event using fullcalendar jQuery would I implement in codeigniter 1.7.2
looking at dribbble, I have started to ask myself, how I would implement a
How would you implement a generic stack without using nsmutablearrays?
I have a following problem. I'm trying to implement a model for my QTreeView
I have the following model: One Entry has n Tags I use a dynamic
I'm looking for a dynamic way to implement search in my MVC 1.0 application.
I have a C#.NET web app and would like to save my underlying Model
I'd like to implement a dynamic property on a Core Data model but am
I would like to implement a Game model, which has two teams and two
How do I implement cross-model fetched properties in a core data model? Simply put,

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.