Sorry for opening the prior thread. Here is a new thread for the message. Please close the thread I opened earlier.
After reading the solution to this issue, as suggested in the following thread, http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=14111, I am still unable to get the NOLOCK optimizer hint applied at the dataaccessadapter level.
I am using LL2.6.
I have a need to set a NOLOCK on a specific connection as well, not globally, due to some legacy code issues. Can anyone post a sample of their implementation of solution that Frans suggested in this thread?
I can't seem to get it to work.
For the subclassed dynamic query engine, I have created a new class in the database specific adapter project:
class CustomNoLockDynamicQueryEngine : SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine
{
public CustomNoLockDynamicQueryEngine(): base()
{
((SqlServerSpecificCreator)Creator).UseNoLockHintsForObjectNames = true;
}
}
I have then also created a separate NoLock DataAccessAdapter class for testing:
public class DataAccessAdapterNoLock : OneShop.Mc.DAL.DatabaseConnector.DataAccessAdapter
{
/// <summary>
/// CTor
/// </summary>
/// <param name="connectionString">The connection string to use when connecting to the database.</param>
public DataAccessAdapterNoLock(string connectionString)
: base(connectionString)
{
}
protected override SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase CreateDynamicQueryEngine()
{
//return base.CreateDynamicQueryEngine();
return new OneShop.Mc.DAL.DatabaseConnector.CustomNoLockDynamicQueryEngine();
}
}
My consuming code is then creating an instance of the new data access adapter class:
OneShop.Mc.DAL.DatabaseConnector.DataAccessAdapterNoLock dataAccessAdapter = new DataAccessAdapterNoLock(connectionString);
ScheduleEntity scheduleEntity = new ScheduleEntity(18646);
dataAccessAdapter.FetchEntity(scheduleEntity);
When I do this, data is retrieved, but when I put tracing in the app to check the sql that is emitted, it does not contain NOLOCk?
Help, anyone?
Thanks.
Can1
In response to the Mtrinder question on the previous thread:
_# Posted on: 27-Aug-2009 22:23:53.
Please open new threads rather than hijacking old ones.
In reference to your question - if you step through the code, does your custom NoLock DQE actually get returned ?
Matt_
My calling code creates my subclassed DataAccessAdapterNoLock code, then initiates a fetch statement. At the time the fetch statement executes, a break point stops on the following line:
return new OneShop.Mc.DAL.DatabaseConnector.CustomNoLockDynamicQueryEngine();
I can then step into the constructor of the CustomNoLockDynamicQueryEngine class I created and I see the UseNoLockHintsForObjectNames field being set:
public CustomNoLockDynamicQueryEngine(): base()
{
//DynamicQueryEngine.UseNoLockHintOnSelects = true;
((SqlServerSpecificCreator)Creator).UseNoLockHintsForObjectNames = true;
}
Once I step out past the
return new OneShop.Mc.DAL.DatabaseConnector.CustomNoLockDynamicQueryEngine();
statement, I step into the
protected override IDbConnection CreateNewPhysicalConnection(string connectionString)
{
#if CF
return new SqlCeConnection(connectionString);
#else
DbConnection toReturn = SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.FactoryToUse.CreateConnection();
toReturn.ConnectionString = connectionString;
return toReturn;
#endif
}
I know the return statement executed above, returning my CustomNoLockDynamicQueryEngine class.
Can1