diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index 52f6c1a..0a1b63d 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -352 \ No newline at end of file +353 \ No newline at end of file diff --git a/Builder/IISUploadHandler/build.txt b/Builder/IISUploadHandler/build.txt index 3ca9062..615be70 100644 --- a/Builder/IISUploadHandler/build.txt +++ b/Builder/IISUploadHandler/build.txt @@ -1 +1 @@ -84 \ No newline at end of file +85 \ No newline at end of file diff --git a/MySQLConnector/Connection.cs b/MySQLConnector/Connection.cs index 195c711..c7a7aa1 100644 --- a/MySQLConnector/Connection.cs +++ b/MySQLConnector/Connection.cs @@ -12,7 +12,7 @@ namespace FLocal.MySQLConnector { internal readonly IDBTraits traits; - private DbConnection connection; +// private DbConnection connection; private string connectionString; private HashSet transactions; @@ -20,8 +20,9 @@ namespace FLocal.MySQLConnector { public Connection(string connectionString, IDBTraits traits) { this.traits = traits; this.connectionString = connectionString; - this.connection = this.traits.createConnection(this.connectionString); - this.connection.Open(); + using(DbConnection connection = this.createConnection()) { + //just testing we can open a connection + } this.transactions = new HashSet(); } @@ -32,53 +33,51 @@ namespace FLocal.MySQLConnector { } private List> _LoadByIds(DbCommand command, ITableSpec table, List ids, bool forUpdate) { - lock(this) { - command.CommandType = System.Data.CommandType.Text; + command.CommandType = System.Data.CommandType.Text; - ParamsHolder paramsHolder = new ParamsHolder(); - List placeholder = new List(); - foreach(string id in ids) { - placeholder.Add(this.traits.markParam(paramsHolder.Add(id))); - } + ParamsHolder paramsHolder = new ParamsHolder(); + List placeholder = new List(); + foreach(string id in ids) { + placeholder.Add(this.traits.markParam(paramsHolder.Add(id))); + } - command.CommandText = "SELECT * FROM " + table.compile(this.traits) + " WHERE " + table.getIdSpec().compile(this.traits) + " IN (" + string.Join(", ", placeholder.ToArray()) + ")" + (forUpdate ? " FOR UPDATE" : ""); - //command.Prepare(); - foreach(KeyValuePair kvp in paramsHolder.data) { - command.AddParameter(kvp.Key, kvp.Value); - } + command.CommandText = "SELECT * FROM " + table.compile(this.traits) + " WHERE " + table.getIdSpec().compile(this.traits) + " IN (" + string.Join(", ", placeholder.ToArray()) + ")" + (forUpdate ? " FOR UPDATE" : ""); + //command.Prepare(); + foreach(KeyValuePair kvp in paramsHolder.data) { + command.AddParameter(kvp.Key, kvp.Value); + } - Dictionary> rawResult = new Dictionary>(); - using(DbDataReader reader = command.ExecuteReader()) { - while(reader.Read()) { - Dictionary row = new Dictionary(); - for(int i=0; i> rawResult = new Dictionary>(); + using(DbDataReader reader = command.ExecuteReader()) { + while(reader.Read()) { + Dictionary row = new Dictionary(); + for(int i=0; i> result = new List>(); - foreach(string id in ids) { - if(rawResult.ContainsKey(id)) { - result.Add(rawResult[id]); - } + List> result = new List>(); + foreach(string id in ids) { + if(rawResult.ContainsKey(id)) { + result.Add(rawResult[id]); } - return result; } + return result; } public List> LoadByIds(ITableSpec table, List ids) { - lock(this) { - using(DbCommand command = this.connection.CreateCommand()) { + using(DbConnection connection = this.createConnection()) { + using(DbCommand command = connection.CreateCommand()) { return this._LoadByIds(command, table, ids, false); } } @@ -151,16 +150,16 @@ namespace FLocal.MySQLConnector { } public List LoadIdsByConditions(ITableSpec table, FLocal.Core.DB.conditions.AbstractCondition conditions, Diapasone diapasone, JoinSpec[] joins, SortSpec[] sorts, bool allowHugeLists) { - lock(this) { - using(DbCommand command = this.connection.CreateCommand()) { + using(DbConnection connection = this.createConnection()) { + using(DbCommand command = connection.CreateCommand()) { return this._LoadIdsByConditions(command, table, conditions, diapasone, joins, sorts, allowHugeLists); } } } public long GetCountByConditions(ITableSpec table, FLocal.Core.DB.conditions.AbstractCondition conditions, JoinSpec[] joins) { - lock(this) { - using(DbCommand command = this.connection.CreateCommand()) { + using(DbConnection connection = this.createConnection()) { + using(DbCommand command = connection.CreateCommand()) { command.CommandType = System.Data.CommandType.Text; @@ -238,7 +237,7 @@ namespace FLocal.MySQLConnector { public List LoadIdsByConditions(FLocal.Core.DB.Transaction _transaction, ITableSpec table, FLocal.Core.DB.conditions.AbstractCondition conditions, Diapasone diapasone, JoinSpec[] joins, SortSpec[] sorts, bool allowHugeLists) { Transaction transaction = (Transaction)_transaction; - lock(this) { + lock(transaction) { using(DbCommand command = transaction.sqlconnection.CreateCommand()) { command.Transaction = transaction.sqltransaction; return this._LoadIdsByConditions(command, table, conditions, diapasone, joins, sorts, allowHugeLists); @@ -316,9 +315,9 @@ namespace FLocal.MySQLConnector { } this.transactions.Clear(); this.transactions = null; - this.connection.Close(); - this.connection.Dispose(); - this.connection = null; +// this.connection.Close(); +// this.connection.Dispose(); +// this.connection = null; } }