Вопрос

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?

Это было полезно?

Решение

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

  1. Use a loop to iterate over each row in table A.
  2. While looping, add the row information from table A, along with the other data that must be copied, to table B.
  3. Verify that the data in table B contains the information you need
  4. Use a loop to iterate over each row in table A again, but this time remove each row.

Hope this helps.

Другие советы

Maybe you should check out Entity Framework Migrations, it is very comprehensive tool for manipulations with database schema. http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-code-based-migrations-walkthrough.aspx

May be this Solution Help for SomeOne stuck on this Problem @Tarzan helped me to complete this

IList<OrderTemp> data = _DBService.GetAllOrderTemp();//List

foreach (var result in data)
{
    Order order = new Order()
    {
        OrderId = result.Id,
        CustomerId = result.CustomerId,
        SchoolNameId = result.SchoolNameId,
        Supplier = result.Supplier,
        StatusId = result.StatusId,
        ProductCode = result.ProductCode,
        ProductDescription = result.ProductDescription,
        Color = result.Color,
        Size = result.Size
    };
    _DBService.InsertOrder(order);
    _DBService.DeleteOrderTemp(result);
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top