Skip to content

Commit 527a31b

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

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

QueryDB/DBContext.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using QueryDB.Resources;
33
using System;
44
using System.Collections.Generic;
5+
using System.Linq;
56
using System.Text.RegularExpressions;
67

78
namespace QueryDB
@@ -200,11 +201,10 @@ public int ExecuteCommand(string sqlStatement)
200201
/// </returns>
201202
public bool ExecuteTransaction(List<string> sqlStatements)
202203
{
203-
foreach(var sqlStatement in sqlStatements)
204+
foreach(var sqlStatement in sqlStatements.Where(sqlStatement => Regex.IsMatch(sqlStatement, "^\\s*SELECT\\s+.*", RegexOptions.IgnoreCase | RegexOptions.Singleline, TimeSpan.FromSeconds(5))))
204205
{
205-
if (Regex.IsMatch(sqlStatement, "^\\s*SELECT\\s+.*", RegexOptions.IgnoreCase | RegexOptions.Singleline, TimeSpan.FromSeconds(5)))
206-
throw new QueryDBException(QueryDBExceptions.ErrorMessage.UnsupportedSelectExecuteTransaction,
207-
QueryDBExceptions.ErrorType.UnsupportedCommand, QueryDBExceptions.AdditionalInfo.UnsupportedSelectExecuteTransaction);
206+
throw new QueryDBException(QueryDBExceptions.ErrorMessage.UnsupportedSelectExecuteTransaction,
207+
QueryDBExceptions.ErrorType.UnsupportedCommand, QueryDBExceptions.AdditionalInfo.UnsupportedSelectExecuteTransaction);
208208
}
209209
if (Database.Equals(DB.MSSQL))
210210
{

0 commit comments

Comments
 (0)