Yes you could. If you want to do it on a general level, you could intercept the calls in the DataAccessAdapter, like this:
public class CommandInterceptorDataAccessAdapter : DataAccessAdapter
{
public CommandInterceptorDataAccessAdapter()
{
}
public CommandInterceptorDataAccessAdapter(bool keepConnectionOpen) : base(keepConnectionOpen)
{
}
public CommandInterceptorDataAccessAdapter(string connectionString) : base(connectionString)
{
}
public CommandInterceptorDataAccessAdapter(string connectionString, bool keepConnectionOpen) : base(connectionString, keepConnectionOpen)
{
}
public CommandInterceptorDataAccessAdapter(string connectionString, bool keepConnectionOpen, CatalogNameUsage catalogNameUsageSetting, string catalogNameToUse) : base(connectionString, keepConnectionOpen, catalogNameUsageSetting, catalogNameToUse)
{
}
public CommandInterceptorDataAccessAdapter(string connectionString, bool keepConnectionOpen, SchemaNameUsage schemaNameUsageSetting, string schemaNameToUse) : base(connectionString, keepConnectionOpen, schemaNameUsageSetting, schemaNameToUse)
{
}
public CommandInterceptorDataAccessAdapter(string connectionString, bool keepConnectionOpen, CatalogNameOverwriteHashtable catalogNameOverwrites, SchemaNameOverwriteHashtable schemaNameOverwrites) : base(connectionString, keepConnectionOpen, catalogNameOverwrites, schemaNameOverwrites)
{
}
protected override IRetrievalQuery CreateSelectDQ(QueryParameters parameters)
{
if(this.GeneratedCommands == null)
{
this.GeneratedCommands = new List<DbCommand>();
}
var toReturn = base.CreateSelectDQ(parameters);
this.GeneratedCommands.Add(toReturn.Command);
return toReturn;
}
public List<DbCommand> GeneratedCommands { get; private set; }
public DbCommand LastGeneratedCommand
{
get
{
if(this.GeneratedCommands == null)
{
return null;
}
return this.GeneratedCommands.Last();
}
}
}
Modify other individual SQL parts individually is also possible but not that trivial. What is what you want to alter/modify exactly? (maybe there is another way).