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
- };
- }

4 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Amit MohantyPosted Mar 2, 2020, 1:03 AM
warner jonnPosted Jun 29, 2020, 1:07 AM
Ravi PatelPosted Mar 2, 2020, 1:28 AM
Kunjahamed PPosted Mar 2, 2020, 1:05 AM