I've read that the ORM object scope object was designed to support multi threading. We have a static class with the following definition:
internal static IObjectScope _os = XBDLPScopeProvider.GetNewObjectScope();
public static IObjectScope ORMScope
{
get { return _os; }
}
- Can methods running in multiple threads safely update persisted objects using the ORMScope (see code below)
- If it is not safe what is the recommended mechanism for doing multiple threadsafe updates.
Ben
public static void SetRequestStatus(Guid requestID, int recordsRead, int recordsAnalyzed)
{
var request = (IStatusParent) GetRunningRequest(requestID);
try
{
// Insert to database
DLPDB.ORMScope.Transaction.Begin();
{
request.Status.RecordsRead = recordsRead;
request.Status.RecordsAnalyzed = recordsAnalyzed;
}
DLPDB.ORMScope.Transaction.Commit();
}
catch (Exception ex)
{
DLPDB.ORMScope..Transaction.Rollback();
throw;
}