Skip to content

Commit c195fc0

Browse files
committed
Code Quality - Simplified loop using the Any LINQ method
1 parent 527a31b commit c195fc0

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

QueryDB/DBContext.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,10 @@ public int ExecuteCommand(string sqlStatement)
201201
/// </returns>
202202
public bool ExecuteTransaction(List<string> sqlStatements)
203203
{
204-
foreach(var sqlStatement in sqlStatements.Where(sqlStatement => Regex.IsMatch(sqlStatement, "^\\s*SELECT\\s+.*", RegexOptions.IgnoreCase | RegexOptions.Singleline, TimeSpan.FromSeconds(5))))
205-
{
204+
var selectExists = sqlStatements.Any(sqlStatement => Regex.IsMatch(sqlStatement, "^\\s*SELECT\\s+.*", RegexOptions.IgnoreCase | RegexOptions.Singleline, TimeSpan.FromSeconds(5)));
205+
if (selectExists)
206206
throw new QueryDBException(QueryDBExceptions.ErrorMessage.UnsupportedSelectExecuteTransaction,
207207
QueryDBExceptions.ErrorType.UnsupportedCommand, QueryDBExceptions.AdditionalInfo.UnsupportedSelectExecuteTransaction);
208-
}
209208
if (Database.Equals(DB.MSSQL))
210209
{
211210
using (var msSqlDBConnection = GetSqlServerConnection())

0 commit comments

Comments
 (0)