ASP.NET MVC 2 更新问题

发布于 2024-10-24 00:32:07 字数 1592 浏览 1 评论 0原文

我想通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北凤男飞 2024-10-31 00:32:07

好像没有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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文