Raju Fodse

Raju Fodse

  • 1.4k
  • 244
  • 29.5k

Fetch Value from Third Level Table

Sep 26 2018 1:29 AM
I Have Three Table Linked with each other. I want to fetch Value from other table How do I write Code. I Try This but Variable 'mythkvalue' returns null value. How I will get value for mythkvalue
  1. [HttpPost]  
  2.         public ActionResult CreateP3(Process process)  
  3.         {  
  4.             var tr = process.StageID + process.PIPENO + process.Status;  
  5.             var checkme = (from x in db.Processes  
  6.                            where x.StageID + x.PIPENO + x.Status == tr && x.Status == "OK"  
  7.                            select x).ToList();  
  8.             var mythkvalue = process.PipeAl.Order.THK;  
  9.   
  10.             if (checkme.Count > 0)  
  11.             {  
  12.                 ModelState.AddModelError("PIPENO""You are trying Duplicate Pipe Entry");  
  13.             }  
  14.             if (ModelState.IsValid)  
  15.             {  
  16.                 if (mythkvalue > 1)  
  17.                 {  
  18.                     process.MPP = 25;  
  19.                 }  
  20.                 process.CuttingSpeed = (process.ActualMeter*1000)/process.CuttingTime;  
  21.                 db.Processes.Add(process);  
  22.                 db.SaveChanges();  
  23.                 return RedirectToAction("IndexP3");  
  24.             }  
  25.   
  26.             var EmpAtnList = db.Attens.ToList();  
  27.             IEnumerable<SelectListItem> AttnList = from s in EmpAtnList.OrderByDescending(s => s.ATTNDATE)  
  28.                                                    select new SelectListItem  
  29.                                                    {  
  30.                                                        Value = s.ATTNSYSID.ToString(),  
  31.                                                        Text = s.ATTNDATE + "--" + s.Emp.EmpName  
  32.                                                    };  
  33.   
  34.             ViewBag.ATTNSYSID = new SelectList(AttnList, "Value""Text");  
  35.   
  36.             //ViewBag.ATTNSYSID = new SelectList(db.Attens, "ATTNSYSID", "EMPCODE", process.ATTNSYSID);  
  37.             ViewBag.StageID = new SelectList(db.OMStages, "StageID""StageName");  
  38.             ViewBag.NextStageID = new SelectList(db.OMStages.OrderBy(x => x.StageValue), "StageID""StageName");  
  39.             ViewBag.PIPENO = new SelectList(db.PipeAls, "PIPENO""PIPENO");  
  40.             ViewBag.Status = new SelectList(db.ValueAddLists.Where(x => x.RefName == "PipeStatus"), "RefValue""Description", process.Status);  
  41.             return View(process);  
  42.         } 

Answers (2)