zeeshan akram

zeeshan akram

  • 1.3k
  • 325
  • 16.6k

How to return multiple object in this senerio.

Mar 2 2020 12:49 AM
Anyone can suggest me How to return these to objects.
  1. public ProductViewModel GetProductByID(int ID) {  
  2.   try {  
  3.    var product = (from p in _db.Products where p.ProductID == ID  
  4.   
  5.     select new {  
  6.      p.PName,  
  7.       p.PDescription,  
  8.       p.Model,  
  9.       p.Condition,  
  10.       p.UnitPrice,  
  11.       p.ManificturedPrice,  
  12.       p.Discount,  
  13.       p.UnitWeight,  
  14.       p.UnitInStock  
  15.     }).FirstOrDefault();  
  16.   
  17.    var productDetail = (from pd in _db.ProductDetails join b in _db.Products on pd.ProductID equals b.ProductID where pd.ProductID == ID select new {  
  18.     pd.ProductID,  
  19.      pd.OS,  
  20.      pd.ProcessorType,  
  21.      pd.RAM,  
  22.      pd.ScreenSize,  
  23.      pd.TouchScreen,  
  24.      pd.BatteryLife,  
  25.      pd.Camera  
  26.    }).ToList();  
  27.   
  28.   
  29.    return new {  
  30.     product,  
  31.     productDetail  
  32.    };  
  33.   
  34.   } 
 

Answers (4)