From fc80b3d8e4e9d1df05d04f3df4da0665c55670d3 Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Fri, 20 Apr 2012 20:46:56 +0400 Subject: [PATCH] LoadIdsByConditions now accepts ColumnSpec idSpec as an argument --- MySQLConnector/Connection.cs | 10 +++++----- Web.Core/DB/IDBConnection.cs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MySQLConnector/Connection.cs b/MySQLConnector/Connection.cs index f556c64..18848b7 100644 --- a/MySQLConnector/Connection.cs +++ b/MySQLConnector/Connection.cs @@ -95,7 +95,7 @@ namespace MySQLConnector { } } - private List _LoadIdsByConditions(DbCommand command, ITableSpec table, Web.Core.DB.conditions.AbstractCondition conditions, Diapasone diapasone, JoinSpec[] joins, SortSpec[] sorts, bool allowHugeLists) { + private List _LoadIdsByConditions(DbCommand command, ITableSpec table, Web.Core.DB.conditions.AbstractCondition conditions, Diapasone diapasone, JoinSpec[] joins, SortSpec[] sorts, ColumnSpec idSpec, bool allowHugeLists) { using(var logger = this.CreateCommandExecutionLogger()) { command.CommandType = System.Data.CommandType.Text; @@ -164,7 +164,7 @@ namespace MySQLConnector { if(diapasone.count >= 0) { queryLimits = "LIMIT " + diapasone.count + " OFFSET " + diapasone.start; } - command.CommandText = logger.commandText = "SELECT " + table.getIdSpec().compile(this.traits) + " " + queryMain + " " + querySorts + " " + queryLimits; + command.CommandText = logger.commandText = "SELECT " + idSpec.compile(this.traits) + " " + queryMain + " " + querySorts + " " + queryLimits; List result = new List(); using(DbDataReader reader = command.ExecuteReader()) { @@ -177,10 +177,10 @@ namespace MySQLConnector { } } - public List LoadIdsByConditions(ITableSpec table, Web.Core.DB.conditions.AbstractCondition conditions, Diapasone diapasone, JoinSpec[] joins, SortSpec[] sorts, bool allowHugeLists) { + public List LoadIdsByConditions(ITableSpec table, Web.Core.DB.conditions.AbstractCondition conditions, Diapasone diapasone, JoinSpec[] joins, SortSpec[] sorts, ColumnSpec idSpec, bool allowHugeLists) { using(DbConnection connection = this.createConnection()) { using(DbCommand command = connection.CreateCommand()) { - return this._LoadIdsByConditions(command, table, conditions, diapasone, joins, sorts, allowHugeLists); + return this._LoadIdsByConditions(command, table, conditions, diapasone, joins, sorts, idSpec, allowHugeLists); } } } @@ -274,7 +274,7 @@ namespace MySQLConnector { lock(transaction) { using(DbCommand command = transaction.sqlconnection.CreateCommand()) { command.Transaction = transaction.sqltransaction; - return this._LoadIdsByConditions(command, table, conditions, diapasone, joins, sorts, allowHugeLists); + return this._LoadIdsByConditions(command, table, conditions, diapasone, joins, sorts, table.getIdSpec(), allowHugeLists); } } } diff --git a/Web.Core/DB/IDBConnection.cs b/Web.Core/DB/IDBConnection.cs index 93630c7..7f8d2bc 100644 --- a/Web.Core/DB/IDBConnection.cs +++ b/Web.Core/DB/IDBConnection.cs @@ -9,7 +9,7 @@ namespace Web.Core.DB { List> LoadByIds(ITableSpec table, List ids); - List LoadIdsByConditions(ITableSpec table, AbstractCondition conditions, Diapasone diapasone, JoinSpec[] joins, SortSpec[] sorts, bool allowHugeLists); + List LoadIdsByConditions(ITableSpec table, AbstractCondition conditions, Diapasone diapasone, JoinSpec[] joins, SortSpec[] sorts, ColumnSpec idSpec, bool allowHugeLists); long GetCountByConditions(ITableSpec table, AbstractCondition conditions, params JoinSpec[] joins); @@ -34,7 +34,7 @@ namespace Web.Core.DB { public static class IDBConnectionExtensions { public static List LoadIdsByConditions(this IDBConnection connection, ITableSpec table, AbstractCondition conditions, Diapasone diapasone, JoinSpec[] joins, SortSpec[] sorts) { - return connection.LoadIdsByConditions(table, conditions, diapasone, joins, sorts, false); + return connection.LoadIdsByConditions(table, conditions, diapasone, joins, sorts, table.getIdSpec(), false); } public static List LoadIdsByConditions(this IDBConnection connection, ITableSpec table, AbstractCondition conditions, Diapasone diapasone, params JoinSpec[] joins) {