Unable to fetch Data from View Model Controller to View,i have properly checked the working of query in LINQpad. However I am missing the conversion of the output of query whic
You create a vm like this:
ProductRegistrationViewModelVM vm = new ProductRegistrationViewModelVM();
Then you assign an IQueryable which returns anonymous types to it. That will not pass. Then you try and add a new instance of your view model to it and that will not work either:
vm.Add(new ProductRegistrationViewModelVM());
Fix
Try this instead:
var vm = ( from p in db.Products
join i in db.Images on p.ProductId equals i.Product_Id
join s in db.Specifications on p.ProductId equals s.Product_Id
select new ProductRegistrationViewModelVM
{
//Product
p.Name,
p.Produt_Code,
p.Description,
//Image
i.Image_Description,
i.Image_Name,
i.image1,
//Specifications
s.Sz_Measurement_Unit,
s.Size,
s.Wg_Measurement_Unit,
s.Weight,
s.Price_Set,
s.Price_Sold
} );
return View( vm.ToList() );
And make sure your view accepts a Model as List.