I am very confused, I am trying in vain to queue several attachments, I have thousands of add-ons to do this, I only want to do the database once.
I use .net 4 and the framework 4 framework, and also added a link to system.data.objects but I still have no overload for SaveChanges
here is my code:
using (TransactionScope scope = new TransactionScope())
{
using (myDbContext context = new myDbContext)
{
foreach (var p in model)
{
var tempProduct = new Products();
IEnumerable<MerchantProductFeedMerchantProd> prod = p.prod;
foreach (var i in prod)
{
var prodText = i.text.FirstOrDefault();
var prodUri = i.uri.FirstOrDefault();
var prodPrice = i.price.FirstOrDefault();
FillTempProduct(feedId, i, tempProduct, supplierId, feedInfo, prodPrice, prodText,
prodUri);
context.Products.Add(tempProduct);
context.SaveChanges(false);
}
scope.Complete();
context.AcceptAllChanges();
}
}
it really beats my head now, so any help would be greatly appreciated.
thank
source
share