@ -31,9 +31,7 @@ namespace FLocal.MySQLConnector {
return connection ;
return connection ;
}
}
public List < Dictionary < string , string > > LoadByIds ( ITableSpec table , List < string > ids ) {
private List < Dictionary < string , string > > _L oadByIds ( DbCommand command , ITableSpec table , List < string > ids , bool forUpdate ) {
lock ( this ) {
using ( DbCommand command = this . connection . CreateCommand ( ) ) {
command . CommandType = System . Data . CommandType . Text ;
command . CommandType = System . Data . CommandType . Text ;
ParamsHolder paramsHolder = new ParamsHolder ( ) ;
ParamsHolder paramsHolder = new ParamsHolder ( ) ;
@ -42,7 +40,7 @@ namespace FLocal.MySQLConnector {
placeholder . Add ( this . traits . markParam ( paramsHolder . Add ( id ) ) ) ;
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 ( ) ) + ")" ;
command . CommandText = "SELECT * FROM " + table . compile ( this . traits ) + " WHERE " + table . getIdSpec ( ) . compile ( this . traits ) + " IN (" + string . Join ( ", " , placeholder . ToArray ( ) ) + ")" + ( forUpdate ? " FOR UPDATE" : "" ) ;
//command.Prepare();
//command.Prepare();
foreach ( KeyValuePair < string , string > kvp in paramsHolder . data ) {
foreach ( KeyValuePair < string , string > kvp in paramsHolder . data ) {
command . AddParameter ( kvp . Key , kvp . Value ) ;
command . AddParameter ( kvp . Key , kvp . Value ) ;
@ -75,6 +73,12 @@ namespace FLocal.MySQLConnector {
}
}
return result ;
return result ;
}
}
public List < Dictionary < string , string > > LoadByIds ( ITableSpec table , List < string > ids ) {
lock ( this ) {
using ( DbCommand command = this . connection . CreateCommand ( ) ) {
return this . _L oadByIds ( command , table , ids , false ) ;
}
}
}
}
}
@ -209,6 +213,16 @@ namespace FLocal.MySQLConnector {
}
}
}
}
public List < Dictionary < string , string > > LoadByIds ( FLocal . Core . DB . Transaction _ transaction , ITableSpec table , List < string > ids ) {
Transaction transaction = ( Transaction ) _ transaction ;
lock ( transaction ) {
using ( DbCommand command = transaction . sqlconnection . CreateCommand ( ) ) {
command . Transaction = transaction . sqltransaction ;
return this . _L oadByIds ( command , table , ids , true ) ;
}
}
}
public void update ( FLocal . Core . DB . Transaction _ transaction , ITableSpec table , string id , Dictionary < string , string > data ) {
public void update ( FLocal . Core . DB . Transaction _ transaction , ITableSpec table , string id , Dictionary < string , string > data ) {
Transaction transaction = ( Transaction ) _ transaction ;
Transaction transaction = ( Transaction ) _ transaction ;
lock ( transaction ) {
lock ( transaction ) {