ASP.NET MVC 2 更新问题
我想通过 ASP.Net MVC 2 中的类而不是表单来更新我的模型。
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(string wo_number)
{
WorkOrder wo = GetWorkOrder(wo_number);
UpdateModel(wo);
camprintRepository.Save();
return RedirectToAction("Details", new { wo_number = wo_number });
}
我从外部源提取信息,我希望它更新我的应用程序数据库中的实体。
public WorkOrder GetWorkOrder (string wo_number)
{
UniFile uFile = uSession.CreateUniFile("WO");
uFile.RecordID = wo_number;
WO wo = new WO();
wo.wo_id = wo_number;
wo.sales_product_code = uFile.ReadNamedField("Sales_Code").ToString();
wo.description = uFile.ReadNamedField("P_Desc").ToString();
wo.part_number = uFile.ReadNamedField("Desc").ToString();
wo.work_order_quantity = uFile.ReadNamedField("Qty_To_Mfg").ToString();
wo.sales_order_quantity = uFile.ReadNamedField("Sod_Qty").ToString();
GetWorkOrderOper(wo);
}
我正在使用 LINQ to SQL,正如您所看到的,有一些从每个工作订单分支出来的子对象。
public void GetWorkOrderOper(WorkOrder wo)
{
UniFile uFile = uSession.CreateUniFile("WPO");
string key = wo.wo_id + "*" + wo.first_routing_sequence;
while(key != wo.wo_id + "*")
{
uFile.RecordID = key;
WPO wpo = new WPO();
wpo.wpo_id = key;
wpo.next_sequence_number = uFile.ReadNamedField("Next_Seq").ToString();
wpo.run_hours = uFile.ReadNamedField("Plan_Run_Lbr_Time").ToString();
key = wo.wo_id + "*" + wpo.next_sequence_number;
wo.WPOs.Add(wpo);
}
}
这不是更新模型,我不知道为什么。任何帮助将不胜感激
I want to update my model through a class and not a form in ASP.Net MVC 2.
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(string wo_number)
{
WorkOrder wo = GetWorkOrder(wo_number);
UpdateModel(wo);
camprintRepository.Save();
return RedirectToAction("Details", new { wo_number = wo_number });
}
I'm pulling the information from an outside source and I want it to update the entities in my applications database.
public WorkOrder GetWorkOrder (string wo_number)
{
UniFile uFile = uSession.CreateUniFile("WO");
uFile.RecordID = wo_number;
WO wo = new WO();
wo.wo_id = wo_number;
wo.sales_product_code = uFile.ReadNamedField("Sales_Code").ToString();
wo.description = uFile.ReadNamedField("P_Desc").ToString();
wo.part_number = uFile.ReadNamedField("Desc").ToString();
wo.work_order_quantity = uFile.ReadNamedField("Qty_To_Mfg").ToString();
wo.sales_order_quantity = uFile.ReadNamedField("Sod_Qty").ToString();
GetWorkOrderOper(wo);
}
I am using LINQ to SQL and as you can see there are some child objects that branch off from each workorder.
public void GetWorkOrderOper(WorkOrder wo)
{
UniFile uFile = uSession.CreateUniFile("WPO");
string key = wo.wo_id + "*" + wo.first_routing_sequence;
while(key != wo.wo_id + "*")
{
uFile.RecordID = key;
WPO wpo = new WPO();
wpo.wpo_id = key;
wpo.next_sequence_number = uFile.ReadNamedField("Next_Seq").ToString();
wpo.run_hours = uFile.ReadNamedField("Plan_Run_Lbr_Time").ToString();
key = wo.wo_id + "*" + wpo.next_sequence_number;
wo.WPOs.Add(wpo);
}
}
This is not updating the models and I'm not sure why. Any help would be greatly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好像没有SubmitChanges?或者是在你的 UpdateModel 中?
另一个原因可能是基础表中没有主键
Seems like there is no SubmitChanges? Or is that in your UpdateModel?
Another cause might be no primary key in your underlying table