How to fetch data from a database, calculate and output to UI RRS feed

  • Question


    My request is pretty easy to understand, I suppose. I have two tables in my database and I want to create a new DataTable which is populated with the results of the following equation for each cell. After the calculation I want to output the result table to the user.

    (expected - observed)/expected

    Now, in case I was unclear, a simple pseudo-example is the following:

    (Table1[1,1] - Table2[1,1])/Table1[1,1]

    What I've written until now, in the control file, is the following:

            public ActionResult BO(Category editcategory)
            {   DataSet dsObserved = new DataSet();
                DataSet dsBaselines = new DataSet();
                var sharesTable = db.Shares.Select(s => new { s.valueSalesShares, s.volumeSalesShares,s.valueDistributionShares,s.volumeDistributionShares }).ToList();
                var baselineTable = db.Baselines.Select(b => new { b.valueSalesBaselines, b.volumeSalesBaselines, b.valueDistributionBaselines, b.volumeDistributionBaselines }).ToList();
                ViewBag.result = baselineTable;
                return View();            

    Do you think that I want is plausible and if so, can you provide a solution or book which I can follow? Because, as I said before, I believe what I ask for is pretty easy to do.

    • Moved by CoolDadTx Monday, March 4, 2019 6:47 PM ASP.NET related
    Monday, March 4, 2019 3:17 PM

All replies

  • FYI.

    It's not called Viewbag View Controller. It's called Model View Controller.

    The MVC forum at ASP.NET forums someone there will point you to a tutorial.

    Monday, March 4, 2019 4:35 PM
  • Please post questions related to MVC in the ASP.NET forums.

    Michael Taylor

    Monday, March 4, 2019 6:47 PM