I have this simple webapi method the use linqtosql to execute some stored procedure:
[Authorize]
[Route("save")]
public IHttpActionResult api_Offert_SAVE(reqOffertSave req)
{
try {
using (var transaction = new TransactionScope())
{
var db2 = new OffertAppContext();
db2.Offert_CLEAR(req.idOffert);
db2.Offert_UPD_Header(req.idOffert, null, req.Title, req.Category, req.DatePickUp, req.DateDelivery, req.idDeliveryType, req.idPaymentType, req.PaymentDetail, req.ShippingDetail,req.idOffertSequel, req.Note);
foreach (var r in req.Regions)
{
int? _idOffertRegion = null;
db2.Offert_ADD_Region(req.idUserLastEdit, req.idOffert, r.Region,ref _idOffertRegion);
var products = req.Products.Where(x => x.idOffertRegion == r.idOffertRegion).ToList();
foreach (var p in products)
{
int? x = null;
if(p.idProduct == 0)
db2.Offert_ADD_ProductDummy_FULL(req.idUserLastEdit, req.idOffert, _idOffertRegion, p.Product, p.idProductService, p.Qty, p.idUnitPrice, p.PriceCustomer, p.SeatsCustomer,p.Discount, ref x);
else
db2.Offert_ADD_Product_FULL(req.idUserLastEdit, req.idOffert, _idOffertRegion, p.idProduct, p.idProductService, p.Qty, p.PriceCustomer, p.SeatsCustomer,p.Discount, ref x);
}
}
db2.Offert_CALCULATE_Totals(req.idOffert);
transaction.Complete();
}
return Ok(1);
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
Al was working fine till yesterday when I have updated the dbml file...
I wonder why I get transaction problem... The application is not in production and in this moment I'm the only who access the database...
In this method I only call stored procedures, why I get "transaction is in doubt" exception ?
MSDTC is enabled on my machine.
As suggested, I checked this question:
Reason for System.Transactions.TransactionInDoubtException
But I'm in a completely different and flat scerario than that...
NOTE:
After some checks I find out that if I remove this line:
db.Offert_CALCULATE_Totals(req.idOffert);
The error stops...
Thanks to support