@@ -4,18 +4,15 @@ public class ExecuteQueryFn : IFunctionCallback
44{
55 public string Name => "execute_sql" ;
66 public string Indication => "Performing data retrieval operation." ;
7- private readonly SqlDriverSetting _setting ;
87 private readonly SqlExecuteService _sqlExecuteService ;
98 private readonly IServiceProvider _services ;
109 private readonly ILogger _logger ;
1110
1211 public ExecuteQueryFn ( IServiceProvider services ,
13- SqlDriverSetting setting ,
1412 SqlExecuteService sqlExecuteService ,
1513 ILogger < ExecuteQueryFn > logger )
1614 {
1715 _services = services ;
18- _setting = setting ;
1916 _sqlExecuteService = sqlExecuteService ;
2017 _logger = logger ;
2118 }
@@ -26,8 +23,8 @@ public async Task<bool> Execute(RoleDialogModel message)
2623 //var refinedArgs = await RefineSqlStatement(message, args);
2724 var dbHook = _services . GetRequiredService < IText2SqlHook > ( ) ;
2825 var dbType = dbHook . GetDatabaseType ( message ) ;
29- var connectionString = _setting . Connections . FirstOrDefault ( x => x . Name . Equals ( args . DataSource , StringComparison . OrdinalIgnoreCase ) ) ? . ConnectionString ;
30- var dbConnectionString = dbHook . GetConnectionString ( message ) ?? connectionString ?? throw new Exception ( "database connection is not found" ) ;
26+ var dbConnectionString = dbHook . GetConnectionString ( message , args . DataSource ) ??
27+ throw new Exception ( "database connection is not found" ) ;
3128
3229 // Print all the SQL statements for debugging
3330 _logger . LogInformation ( "Executing SQL Statements: {SqlStatements}" , string . Join ( "\r \n " , args . SqlStatements ) ) ;
0 commit comments