c# - MVC Combine data from two different tables into one view -
lately have been trying mvc. finished mvc tutorial on asp.net website of microsoft. trying figure out how should apply following database design in model class (c#) code of application working on, experiencing trouble.
i want know how can add productcategory model:
my model class:
namespace myprojectname.models { public class shoppingcartitems { public virtual int id { get; set; } [required] [display(name="product name")] public virtual string productname { get; set; } //[display(name="category")] //public virtual int categoryname { get; set; } [display(name="date")] public virtual datetime dateadded { get; set; } [required] [datatype(datatype.currency)] public virtual decimal productprice { get; set; } public virtual int amountavailable { get; set; } } }
shoppingcartitems should displays entries of products table. far know should possible scaffold of tables , display of products categories on 1 page.
can explain me how such mvc model class (or need add query controller class?) need in order show categories on index view belonging products displayed? should need make object of type categories , add properties?
yes, should create class category. product class should have list property.
when pass list of products view know categories have.
without more information on data layer technology using can't give more examples sorry.
Comments
Post a Comment