From e97463761924ce26f0a2ce170e90291822e3d656 Mon Sep 17 00:00:00 2001 From: Anton Ivanov Date: Tue, 27 Aug 2024 12:24:31 +0300 Subject: [PATCH] removed top 1 from query --- .../Desktop/DbLayer/DbBuildingSettings.cs | 2 +- .../org.ohdsi.cdm.framework/Desktop/DbLayer/DbChunk.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sources/Framework/org.ohdsi.cdm.framework/Desktop/DbLayer/DbBuildingSettings.cs b/sources/Framework/org.ohdsi.cdm.framework/Desktop/DbLayer/DbBuildingSettings.cs index 1931fa08..73a5837b 100644 --- a/sources/Framework/org.ohdsi.cdm.framework/Desktop/DbLayer/DbBuildingSettings.cs +++ b/sources/Framework/org.ohdsi.cdm.framework/Desktop/DbLayer/DbBuildingSettings.cs @@ -13,7 +13,7 @@ public class DbBuildingSettings(string connectionString) public int? GetBuildingId(string sourceConnectionString, string vocabularyConnectionString, Vendor vendor) { - const string query = "SELECT TOP 1 [BuildingId] FROM [BuildingSettings] where [SourceConnectionString] = '{0}' and [VocabularyConnectionString] = '{1}' and [Vendor] = '{2}' ORDER BY [BuildingId] desc "; + const string query = "SELECT [BuildingId] FROM [BuildingSettings] where [SourceConnectionString] = '{0}' and [VocabularyConnectionString] = '{1}' and [Vendor] = '{2}' ORDER BY [BuildingId] desc "; using var connection = SqlConnectionHelper.OpenMssqlConnection(_connectionString); using var cmd = SqlConnectionHelper.CreateCommand(string.Format(query, sourceConnectionString, vocabularyConnectionString, vendor), connection); diff --git a/sources/Framework/org.ohdsi.cdm.framework/Desktop/DbLayer/DbChunk.cs b/sources/Framework/org.ohdsi.cdm.framework/Desktop/DbLayer/DbChunk.cs index 1c300295..b7262c3f 100644 --- a/sources/Framework/org.ohdsi.cdm.framework/Desktop/DbLayer/DbChunk.cs +++ b/sources/Framework/org.ohdsi.cdm.framework/Desktop/DbLayer/DbChunk.cs @@ -73,7 +73,7 @@ public bool AllChunksStarted(int buildingId) using var connection = SqlConnectionHelper.OpenMssqlConnection(_connectionString); using var transaction = connection.BeginTransaction(); var query = - $"SELECT TOP 1 Id FROM Chunk WHERE BuildingId = {buildingId} AND Started is null"; + $"SELECT Id FROM Chunk WHERE BuildingId = {buildingId} AND Started is null"; using var cmd = SqlConnectionHelper.CreateCommand(query, connection, transaction); using var reader = cmd.ExecuteReader(); while (reader.Read()) @@ -89,7 +89,7 @@ public bool AllChunksComplete(int buildingId) using var connection = SqlConnectionHelper.OpenMssqlConnection(_connectionString); using var transaction = connection.BeginTransaction(); var query = - $"SELECT TOP 1 Id FROM Chunk WHERE BuildingId = {buildingId} AND Ended is null"; + $"SELECT Id FROM Chunk WHERE BuildingId = {buildingId} AND Ended is null"; using var cmd = SqlConnectionHelper.CreateCommand(query, connection, transaction); using var reader = cmd.ExecuteReader(); while (reader.Read()) @@ -154,7 +154,7 @@ public void MarkUncompletedChunks(int buildingId, int builderId) { var orderBy = orderByDesc ? " ORDER BY 1 DESC" : ""; var query = - $"SELECT TOP 1 Id FROM Chunk with (updlock) WHERE BuildingId = {buildingId} AND Started is null{orderBy}"; + $"SELECT Id FROM Chunk with (updlock) WHERE BuildingId = {buildingId} AND Started is null{orderBy}"; using (var cmd = SqlConnectionHelper.CreateCommand(query, connection, transaction)) {