实体框架codeFirst将数据从一个表到另一个 [英] Entity Framework CodeFirst Move Data From One table To another

查看:116
本文介绍了实体框架codeFirst将数据从一个表到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用实体框架(4.3)code首先方法我Asp.Net MVC3 Application.I想做的事:表A的数据必须之后被复制(以及一些其他数据)表B当点击保存按钮塔布拉A数据将被删除如何实现这一点?

I'm using Entity Framework(4.3) Code First Method For My Asp.Net Mvc3 Application.I want to do:Data of table A must be copied (along with some other data) to table B after that when Click Save Button Tabla A Data will be Removed how to implement this?

推荐答案

下面是逻辑要采取的步骤。添加以下到Save按钮的点击事件:

Here are the logical steps to take. Add the following to the Save button's click event:


  1. 使用循环遍历每一行表A

  2. 当循环,增加从表A中的一行信息,与必须被复制,表B中的其他数据。

  3. 验证表B中的数据包含了你所需要的信息

  4. 使用循环再遍历表A中的每一行,但这次删除的每一行。

希望这有助于。

这篇关于实体框架codeFirst将数据从一个表到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆