zeeshan akram

zeeshan akram

  • 1.4k
  • 325
  • 18k

local variable anonymous type how to resolve this issue.

Mar 2 2020 2:40 AM
Any Expert can resolve this problem.
  1. public class productviewModel     
  2. {    
  3.   public Product listProducts { getset; }    
  4.         public List<ProductDetail> listProductDetails { getset; }    
  5. }   
function 
  1. public ProductViewModel GetProductByID(int ID)  
  2.         {  
  3.             ProductViewModel listprod = new ProductViewModel();  
  4.              
  5.             try  
  6.             {  
  7.                 var productsl = (from p in _db.Products  
  8.                                where p.ProductID == ID  
  9.   
  10.                                select new  
  11.                                {  
  12.                                    p.PName,  
  13.                                    p.PDescription,  
  14.                                    p.Model,  
  15.                                    p.Condition,  
  16.                                    p.UnitPrice,  
  17.                                    p.ManificturedPrice,  
  18.                                    p.Discount,  
  19.                                    p.UnitWeight,  
  20.                                    p.UnitInStock  
  21.                                }).FirstOrDefault();  
  22.   
  23.               var productD = (from pd in _db.ProductDetails  
  24.                                      join b in _db.Products on pd.ProductID equals b.ProductID  
  25.                                      where pd.ProductID == ID  
  26.                                      select new  
  27.                                      {  
  28.                                          pd.ProductID,  
  29.                                          pd.OS,  
  30.                                          pd.ProcessorType,  
  31.                                          pd.RAM,  
  32.                                          pd.ScreenSize,  
  33.                                          pd.TouchScreen,  
  34.                                          pd.BatteryLife,  
  35.                                          pd.Camera  
  36.                                      }).ToList();  
  37.   
  38.                 listprod.listProducts = productsl;  
  39.                 listprod.listProductDetails = productD;  
  40.                 return listprod;  
  41.             }  
  42.   
  43.             catch (Exception)  
  44.             {  
  45.   
  46.                 throw;  
  47.             }  
  48.   
  49.         }
Error 
 
productsl
 
 
productD
 

Answers (2)