I have a C# MVC project with a database first approach. I also have to tables Products and Company. The product has a foreign key to the company table. I want to be able to load the product as a model yet be able to show the company code and logo with the product information.
I have looked at a lot of different articles etc but it doesn't seem to answer my question.
I'm not new to C# ASP.NET but am new to the MVC side.
Loading
Jonathan MeyerPosted Jan 22, 2015, 3:04 AM
From the model created by EF I already have a List (even though its a 1 to many from the product side) ...Just for information purposes.
I'm going to create the VM in the BLL and the actual models are in my DAL library
Bhavik PatelPosted Jan 22, 2015, 2:55 AM
ProductCompanyModel
{
public string ProductName{get;set;}
public string ProductCategory{get;set;}
public string CompanyName{get;set;}
public string logo{get;set;}
}
if you are showing list of data then
@foreach(var item in ViewBag.Data as List
{
// show your data
}
if you are showing data as single page take ProductCompanyModel as @model
Hope you will get your solution
Thanks and Regards,
Bhavik Patel