Anyone can suggest me How to return these to objects.
- public ProductViewModel GetProductByID(int ID) {
- try {
- var product = (from p in _db.Products where p.ProductID == ID
- select new {
- p.PName,
- p.PDescription,
- p.Model,
- p.Condition,
- p.UnitPrice,
- p.ManificturedPrice,
- p.Discount,
- p.UnitWeight,
- p.UnitInStock
- }).FirstOrDefault();
- var productDetail = (from pd in _db.ProductDetails join b in _db.Products on pd.ProductID equals b.ProductID where pd.ProductID == ID select new {
- pd.ProductID,
- pd.OS,
- pd.ProcessorType,
- pd.RAM,
- pd.ScreenSize,
- pd.TouchScreen,
- pd.BatteryLife,
- pd.Camera
- }).ToList();
- return new {
- product,
- productDetail
- };
- }


Amit MohantyRank #112 · 20K reputationPosted Mar 1, 2020, 8:03 PM EST
Kunjahamed PRank #5,790 · 286 reputationPosted Mar 1, 2020, 8:05 PM EST
Ravi PatelRank #439 · 5.7K reputationPosted Mar 1, 2020, 8:28 PM EST