我已经创建了实体框架对象来从MVC中的其他表中获取数据。但是我的上下文无法刷新,并且每次返回旧值时都无法刷新。下面是代码。
LPDBContext newdb = new LPDBContext();
//using (LPDBContext newdb = new LPDBContext())
var objectContext = ((IObjectContextAdapter)newdb).ObjectContext;
var MyThk = (from ot in newdb.Processes
join v in newdb.PipeAls on ot.PIPENO equals v.PIPENO
join c in newdb.Orders on v.OrderSYSID equals c.OrderSYSID
select c.THK).FirstOrDefault().GetValueOrDefault();
objectContext.Refresh(RefreshMode.StoreWins, MyThk);
if (ModelState.IsValid)
{
//if ((MyThk >= 6 && MyThk <= 12) /*&& (MyDia >= 1 && MyDia <= 108) && (MyLength >= 5 && MyLength <= 7)*/)
if (MyThk>10)
{
process.MPP = 80;
process.TPCPL = 3;
}
else
{
process.MPP = 10;
}
process.CuttingSpeed = (process.ActualMeter*1000)/process.CuttingTime;
newdb.Processes.Add(process);
newdb.SaveChanges();
return RedirectToAction("IndexP3");
}