static void AddNewOrders(IEnumerable<object[]> orderInfos)
{
using (NorthwindEntities northwindEntities = new NorthwindEntities())
{
using (TransactionScope scope = new TransactionScope())
{
foreach (object[] orderInfo in orderInfos)
{
Order order = new Order()
{
CustomerID = (orderInfo[0] as string),
EmployeeID = (orderInfo[1] as int?),
OrderDate = (orderInfo[2] as DateTime?),
RequiredDate = (orderInfo[3] as DateTime?),
ShippedDate = (orderInfo[4] as DateTime?),
ShipVia = (orderInfo[5] as int?),
Freight = (orderInfo[6] as decimal?),
ShipName = (orderInfo[7] as string),
ShipAddress = (orderInfo[8] as string),
ShipCity = (orderInfo[9] as string),
ShipRegion = (orderInfo[10] as string),
ShipPostalCode = (orderInfo[11] as string),
ShipCountry = (orderInfo[12] as string),
};
northwindEntities.Orders.Add(order);
}
northwindEntities.SaveChanges();
scope.Complete();
}
}
}