Database.SqlQuery thread safety

Viewed 420

Does anybody know if Database.SqlQuery does something under the hood that would make it thread-unsafe (like creating or enlisting a transaction, etc.)?

This is the piece of code that I have to call from multiple threads - the query is very straight-forward, hardcoded (no access to shared user-code data):

public virtual long GetId(string sql)
{
    var newid = DbContext.Database.SqlQuery<long>(sql).First();
    return newid;
}

My goal is to get by during a minor release - then we will have a chance to properly implement synchronization if needed.

1 Answers
Related