问题描述
我正在开发ASP.net MVC4网络应用程序。有Product,ProductProperty,ProductCategory模型:
I'm working on ASP.net MVC4 web app. There are Product, ProductProperty, ProductCategory models:
public class Product
{
public int Id { get;set;}
public string Name {get;set;}
public byte ProductCategoryId { get; set;}
public virtual ProductCategory ProductCategory {get; set;}
public List<PropertyValue> PropertyValues {get;set;}
}
public class ProductProperty
{
public int Id { get; set; }
public string Name{ get;set;}
public virtual List<PropertyValue> PropertyValues{get;set;}
public virtual List<ProductCategory> ProductCategories{get;set;}
}
public class ProductCategory
{
public byte Id {get;set;}
public string Name { get; set;}
public List<Product> Products;
public virtual List<ProductProperty> ProductProperties {get; set;}
}
每件产品都属于类别,每件产品属性适用于一个或多个类别,产品型号具有依赖于类别的属性值列表。
我不知道如何实现产品的创建和编辑视图和控制器操作。
当产品发送到创建视图时,其类别未被选中,但在选择之后应该有回发或ajax,这将创建具有ProductProperties的PropertyValues的DropDownLists被引用选中类别。然后在最终发布后,带有PropertyValues列表的Product对象应保存在DB中。
这真令人困惑,如果有简单优雅的解决方案,请提供建议。
谢谢!
Each product reffers to category and each product property applies to one or more categories, Product model has List of property values which depends on category.
I do not know how to implement Create and Edit views and controller actions for products.
When product send to Create view its category is not selected, but after it selected there should be post back or ajax which would create DropDownLists with PropertyValues of ProductProperties reffered to selected Category. Then after final post Product object with List of PropertyValues should be saved in DB.
That is really confusing, please advice if there simple and elegant solution.
Thank you!
推荐答案
这篇关于依赖于另一个属性的复杂类型列表的编辑器模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!