Emmmanuel FIADUFE

Emmmanuel FIADUFE

  • 784
  • 1.1k
  • 55.4k

Fetch Data query from MVC controller is not showing 2 columns

Mar 20 2023 10:15 AM

Please in my controller I have this code to fetch data from two tables in the database, it fetches the data alright but Quantity and TotalAmount amount is not coming. thank you.

public ActionResult getNewOrder()
{
    ASPNETMASTERPOSTEntities db = new ASPNETMASTERPOSTEntities();
    var dataList = db.tblSales.Include("tblSalesDetails").ToList();
    var modifiedData = dataList.Select(x => new
    {
       SalesDetailId = x.SalesDetailId,
        Quantity = x.Quantity,
        ProductId = x.ProductId,
        ProductName = x.tblProduct.ProductName,
        SalesId = x.SalesId,
        OrderDate = x.OrderDate,
        SubTotal = x.SubTotal,
        DiscountPercent = x.DiscountPercent,
        VatPercent = x.VatPercent,
        TotalAmount = x.TotalAmount
    }).ToList();
    return Json(modifiedData, JsonRequestBehavior.AllowGet);

}

 


Answers (7)