Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 24, 2012 03:01 PM by eric2820
Nov 23, 2012 04:27 PM|LINK
Hi. I have a web application hosted on a webserver, done using Linq-to-sql. I have used the general Linq-to-SQL update statements, and when an update is done to a record from a single user, it updates without any problems. However, when many are using the
same update page at the same time, which uses the same data context, it shuffles by updating the wrong record requested by another user, rather than the original source. I am just using the Unique Record ID ro identify the updating record, and just use context.SaveChanges()
to commit the changes.
Can any one suggest what I am doing wrong here. As I have said, I am using Linq-to_SQL, I have used optimistic concurrency aswell.
Nov 23, 2012 07:49 PM|LINK
It's impossible to diagnose your issue without seeing the code that you're having an issue with.
Nov 24, 2012 03:06 AM|LINK
Here is a code sample which I am using to update.
public static bool UpdateRecord(Ledger_Brand RecordSet, int StaffID)
using (dbLedger db = new dbLedger())
var updateRecord = (from e in db.Ledger_Brands
where e.BrandID == RecordSet.BrandID
updateRecord.BrandName = RecordSet.BrandName;
updateRecord.RecordStatus = RecordSet.RecordStatus;
FacilitatorRepository.InsertTransactionLog("Ledger_Brand", StaffID, 0, RecordSet.BrandID);
foreach (ObjectChangeConflict obj in db.ChangeConflicts)
catch (Exception ex)
Nov 24, 2012 08:04 AM|LINK
I think you can just set Confliction in the Submit method：
For more you can download the sample here：http://www.codeproject.com/Articles/38299/How-To-Handle-Concurrency-in-LINQ-to-SQL
Nov 24, 2012 03:01 PM|LINK
What would happend if you allowed only one user at a time into that code?
Just how heavely is that method being called?
I would at least consider putting a Lock statment at the start of that method to limit it to 1 executaion at a time.