Reputation: 13
I have two tables Cart(ItemID, Name, Price, Quantity, CartID, CustID)
and PP( invoiceID, itemID, orderQuantity, PricePerUnit, includesID)
.
Now I have to insert values (ItemID, Price, Quantity
) from the Cart
table into the pp
table where cart.custid = session[customerID]
. But the values not getting inserted into the pp
table. Not sure if the AsEnumerable
syntax used here is correct.
DataClassesDataContext context = new DataClassesDataContext();
var Carts = context.Carts;
pp newpp = new pp();
var p = Carts.AsEnumerable().Select(x => new pp()
{
itemID = x.ItemID,
PricePerUnit = Convert.ToDouble(x.Price),
orderQuantity = x.Quantity,
invoiceID = invoiceNum
});
context.pps.InsertAllOnSubmit(p);
Upvotes: 1
Views: 1775