本文整理汇总了C#中IDbTransaction.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# IDbTransaction.Commit方法的具体用法?C# IDbTransaction.Commit怎么用?C# IDbTransaction.Commit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDbTransaction
的用法示例。
在下文中一共展示了IDbTransaction.Commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Commit
public void Commit()
{
if(Connection.State != ConnectionState.Open)
Connection.Open();
_transaction = Connection.BeginTransaction();
try
{
// run updates
foreach (var command in _nonQueryActions)
{
command.Execute();
}
_transaction.Commit();
_nonQueryActions.Clear();
_transaction = null;
}
catch(Exception)
{
_transaction?.Rollback();
throw;
}
}
示例2: CommitIDbTransaction
public static void CommitIDbTransaction(IDbTransaction st)
{
try
{
IDbConnection myconn = st.Connection;
st.Commit();
if (myconn != null)
{
if (myconn.State != ConnectionState.Closed)
{
myconn.Close();
myconn.Dispose();
}
}
}
catch (Exception err)
{
IDbConnection myconn = st.Connection;
st.Rollback();
if (myconn != null)
{
if (myconn.State != ConnectionState.Closed)
{
myconn.Close();
myconn.Dispose();
}
}
throw new Exception(CBB.ExceptionHelper.ExpressionPaser.ErrTrim(err));
}
}
示例3: Exception
public static void f_结束IDbTransaction(IDbTransaction st)
{
try
{
IDbConnection myconn = st.Connection;
st.Commit();
if (myconn != null)
{
if (myconn.State != ConnectionState.Closed)
{
myconn.Close();
myconn.Dispose();
}
}
}
catch (Exception err)
{
IDbConnection myconn = st.Connection;
st.Rollback();
if (myconn != null)
{
if (myconn.State != ConnectionState.Closed)
{
myconn.Close();
myconn.Dispose();
}
}
throw new Exception(NESCBB.ExpressionHelper.c_错误信息类.f_Sql错误处理(err));
}
}
示例4: Transpor
public void Transpor()
{
conexão = ObterConexãoAberta();
transação = conexão.BeginTransaction();
Dictionary<string, bool> referências = ObterHashExisteReferência();
ApagaFornecedores();
CadastrarFornecedores(ObtemLegadoFornecedoresParaCadastrar());
CadastrarVínculos();
SobrescreveInicio(referências);
transação.Commit();
conexão.Close();
}
示例5:
/// <summary>
/// Закрыть транзакцию
/// </summary>
/// <param name="transaction"></param>
public static void СommitTransaction(IDbTransaction transaction) {
if (transaction != null) {
var v_storedConn = transaction.Connection;
transaction.Commit();
transaction.Dispose();
if (v_storedConn != null) {
v_storedConn.Close();
v_storedConn.Dispose();
}
}
}
示例6: Execute
public void Execute ()
{
SessionFactoryFactory.CreateIndexes(memConn);
transaction.Commit();
if(String.IsNullOrEmpty(diskFilepath))
return;
lock (ioMutex)
{
if (!File.Exists(diskFilepath))
{
(memConn as System.Data.SQLite.SQLiteConnection).SaveToDisk(diskFilepath);
}
else
{
memConn.ExecuteNonQuery("ATTACH DATABASE '" + diskFilepath.Replace("'", "''") + "' AS disk");
memConn.ExecuteNonQuery("PRAGMA disk.journal_mode=OFF; PRAGMA disk.synchronous=OFF;");
transaction = memConn.BeginTransaction();
memConn.ExecuteNonQuery("INSERT INTO disk.Protein SELECT * FROM Protein");
memConn.ExecuteNonQuery("INSERT INTO disk.ProteinMetadata SELECT * FROM ProteinMetadata");
memConn.ExecuteNonQuery("INSERT INTO disk.ProteinData SELECT * FROM ProteinData");
memConn.ExecuteNonQuery("INSERT INTO disk.Peptide SELECT * FROM Peptide");
memConn.ExecuteNonQuery("INSERT INTO disk.PeptideSequences SELECT * FROM PeptideSequences");
memConn.ExecuteNonQuery("INSERT INTO disk.PeptideInstance SELECT * FROM PeptideInstance");
memConn.ExecuteNonQuery("INSERT INTO disk.SpectrumSourceGroup SELECT * FROM SpectrumSourceGroup");
memConn.ExecuteNonQuery("INSERT INTO disk.SpectrumSource SELECT * FROM SpectrumSource");
memConn.ExecuteNonQuery("INSERT INTO disk.SpectrumSourceMetadata SELECT * FROM SpectrumSourceMetadata");
memConn.ExecuteNonQuery("INSERT INTO disk.SpectrumSourceGroupLink SELECT * FROM SpectrumSourceGroupLink");
memConn.ExecuteNonQuery("INSERT INTO disk.Spectrum SELECT * FROM Spectrum");
memConn.ExecuteNonQuery("INSERT INTO disk.Analysis SELECT * FROM Analysis");
memConn.ExecuteNonQuery("INSERT INTO disk.AnalysisParameter SELECT * FROM AnalysisParameter");
memConn.ExecuteNonQuery("INSERT INTO disk.PeptideSpectrumMatch SELECT * FROM PeptideSpectrumMatch");
memConn.ExecuteNonQuery("INSERT INTO disk.PeptideSpectrumMatchScoreName SELECT * FROM PeptideSpectrumMatchScoreName");
memConn.ExecuteNonQuery("INSERT INTO disk.PeptideSpectrumMatchScore SELECT * FROM PeptideSpectrumMatchScore");
memConn.ExecuteNonQuery("INSERT INTO disk.Modification SELECT * FROM Modification");
memConn.ExecuteNonQuery("INSERT INTO disk.PeptideModification SELECT * FROM PeptideModification");
memConn.ExecuteNonQuery("INSERT OR IGNORE INTO disk.IntegerSet SELECT * FROM IntegerSet");
memConn.ExecuteNonQuery("INSERT INTO disk.QonverterSettings SELECT * FROM QonverterSettings");
/*foreach (var itr in insertCommandByTable)
{
IDbCommand cmd = itr.Key;
foreach (var row in itr.Value)
{
setParameters(cmd, row);
cmd.ExecuteNonQuery();
}
}*/
transaction.Commit();
memConn.ExecuteNonQuery("DETACH DATABASE disk");
}
}
}
示例7: Execute
/// <summary>
/// The execute.
/// </summary>
/// <param name="dbfunctionType">
/// The dbfunction type.
/// </param>
/// <param name="operationName">
/// The operation name.
/// </param>
/// <param name="parameters">
/// The parameters.
/// </param>
/// <param name="result">
/// The result.
/// </param>
/// <param name="transaction"></param>
/// <returns>
/// The execute.
/// </returns>
public virtual bool Execute(
DbFunctionType dbfunctionType,
[NotNull] string operationName,
[NotNull] IEnumerable<KeyValuePair<string, object>> parameters,
[CanBeNull] out object result,
IDbTransaction transaction = null)
{
if (this.IsSupportedOperation(operationName))
{
this._sqlMessages.Clear();
bool createdTransaction = transaction == null;
try
{
if (transaction == null)
{
transaction = this.DbAccess.BeginTransaction();
}
if (transaction.Connection is SqlConnection)
{
var sqlConnection = transaction.Connection as SqlConnection;
sqlConnection.FireInfoMessageEventOnUserErrors = true;
sqlConnection.InfoMessage += new SqlInfoMessageEventHandler(this.sqlConnection_InfoMessage);
var operationSuccessful = this.RunOperation(sqlConnection, transaction, dbfunctionType, operationName, parameters, out result);
if (createdTransaction && operationSuccessful)
{
transaction.Commit();
}
return operationSuccessful;
}
}
finally
{
if (createdTransaction && transaction != null)
{
transaction.Dispose();
}
}
}
result = null;
return false;
}
示例8: CommitTransaction
private void CommitTransaction(IDbTransaction tran)
{
tran.Commit();
instrumentation.TransactionCommitted();
}
示例9: EndUpdate
public void EndUpdate(IDbTransaction trans)
{
trans.Commit();
trans.Dispose();
m_conn.Close();
m_conn = null;
}
示例10: ExecuteNonQuery
public static int ExecuteNonQuery(IDbTransaction st, String sql, IDbDataParameter[] sp, CommandType commaneType, bool AllComplete)
{
if (st == null)
{
throw new Exception("本方法调用需要传入一个有效的事务,本次调用传入事务为Null");
}
try
{
int returnvalue = 0;
if (GetDBType(st.Connection.ConnectionString) == OperationDBType.SQLLite)
{
returnvalue = SqliteHelper.ExecuteNonQuery((SqliteTransaction)st, commaneType, sql, (SqliteParameter[])sp);
}
else if (GetDBType(st.Connection.ConnectionString) == OperationDBType.SQL)
{
returnvalue = SqlHelper.ExecuteNonQuery((SqlTransaction)st, commaneType, sql, (SqlParameter[])sp);
}
if (AllComplete)
{
IDbConnection myconn = st.Connection;
st.Commit();
if (myconn != null)
{
if (myconn.State != ConnectionState.Closed)
{
myconn.Close();
myconn.Dispose();
}
}
}
return returnvalue;
}
catch (Exception err)
{
IDbConnection myconn = st.Connection;
st.Rollback();
if (myconn != null)
{
if (myconn.State != ConnectionState.Closed)
{
myconn.Close();
myconn.Dispose();
}
}
throw new Exception(CBB.ExceptionHelper.ExpressionPaser.ErrTrim(err));
}
}
示例11: CommitTransaction
private void CommitTransaction(IDbTransaction trans)
{
if (trans == null) return;
trans.Commit();
}
示例12: ExecuteSql
public DataTable ExecuteSql(string query)
{
_Connection.Open();
_Transaction = _Driver.BeginTransaction(_Connection);
IDbCommand cmd = _Driver.CreateCommand(query, _Connection, _Transaction);
if (TraceSqlSwitch.Enabled)
{
TraceHelpler.Trace(cmd, _Dialect);
}
DataTable result = new DataTable();
using (IDataReader reader = cmd.ExecuteReader())
{
result.Load(reader);
}
_Transaction.Commit();
_Connection.Close();
return result;
}
示例13: CommitTransaction
static void CommitTransaction(IDbTransaction tran)
{
tran.Commit();
}
示例14: LoadScalar
public override object LoadScalar(OPath.OPathQuery query)
{
if (query.QueryType == OPathQueryTypeEnum.Path)
{
query.QueryType = OPathQueryTypeEnum.Expression;
query.Expression = new OPath.Expressions.Call("eval", new Evaluant.OPath.Expressions.Collections.ConstraintCollection(new OPath.Expressions.Constraint[] { query.Path }));
}
SqlMapperTransformer transformer = new SqlMapperTransformer(_Mapping, _Model);
transformer.Dialect = Dialect;
ISQLExpression exp = transformer.TransformScalar(query);
_Connection.Open();
_Transaction = _Connection.BeginTransaction();
object result = null;
try
{
string[] queries = Dialect.RenderQueries(exp);
IDbCommand command = Driver.CreateCommand(queries[queries.Length - 1], _Connection, _Transaction);
if (TraceSqlSwitch.Enabled)
{
TraceHelpler.Trace(command, _Dialect);
}
object res = command.ExecuteScalar();
if (res != DBNull.Value)
result = res;
_Transaction.Commit();
}
catch
{
_Transaction.Rollback();
throw;
}
finally
{
_Connection.Close();
}
// Ensure the result in an Int32 in case of a count()
if (query.Expression.Operands[0] is OPath.Expressions.Function
&& ((OPath.Expressions.Function)query.Expression.Operands[0]).Type == Evaluant.OPath.Expressions.FunctionEnum.Count)
result = Convert.ToInt32(result);
return result;
}
示例15: LoadReference
//.........这里部分代码省略.........
{
foreach (string q in _Dialect.RenderQueries(exp, Driver))
{
IDbCommand command = _Driver.CreateCommand(q, _Connection, _Transaction);
if (TraceSqlSwitch.Enabled)
{
TraceHelpler.Trace(command, _Dialect);
}
using (IDataReader reader = command.ExecuteReader())
{
EntityMapping entityChild = _Mapping.Entities[referenceModel.ChildType];
EntityMapping baseEntityChild = entityChild;
string parentId = String.Empty;
string refId = null; //String.Empty; Empty string can be the value
Entity parentEntity = null, reference = null;
while (reader.Read())
{
string trueType = reader[SqlMapperTransformer.TYPE_ALIAS].ToString();
if (baseEntityChild == null || baseEntityChild.Type != trueType)
entityChild = _Mapping.Entities[trueType];
if (entityChild == null)
throw new MappingNotFoundException(string.Format("The entity [{0}] could not be found the mapping", trueType));
int nbParentIds = _Mapping.Entities[referenceModel.ParentType].Ids.Count;
string[] newParentIds = new string[nbParentIds];
for (int indexId = 0; indexId < nbParentIds; indexId++)
newParentIds[indexId] = reader.GetValue(reader.GetOrdinal("ParentId" + (nbParentIds == 1 ? "" : indexId.ToString()))).ToString().Trim();
string newParentId = string.Join(SqlMapperProvider.IDSEP.ToString(), newParentIds);
int nbChildIds = entityChild.Ids.Count;
string[] newChildIds = new string[nbChildIds];
for (int indexId = 0; indexId < nbChildIds; indexId++)
{
if (entityChild.Ids[indexId].Generator.Name == Evaluant.Uss.SqlMapper.GeneratorMapping.GeneratorType.business)
newChildIds[indexId] = reader[entityChild.GetIdFieldAs(entityChild.Ids[indexId])].ToString().Trim();
else
newChildIds[indexId] = reader.GetValue(1 + nbParentIds + indexId).ToString().Trim();
}
string newReferenceId = string.Join(SqlMapperProvider.IDSEP.ToString(), newChildIds);
// Go the next parent
if (parentId != newParentId)
{
if (parentEntity != null)
parentEntity.State = State.UpToDate;
parentId = newParentId;
parentEntity = entityIndex[parentId] as Entity;
refId = null; //String.Empty; Empty string can be the value
}
// Create a new reference
if (refId != newReferenceId)
{
if (reference != null)
reference.State = State.UpToDate;
reference = new Entity(entityChild.Type);
refId = newReferenceId;
reference.Id = refId;
parentEntity.AddValue(refName, reference, State.UpToDate);
}
ImportAttributes(reader, new string[] { }, _Mapping.Entities[reference.Type], reference, transformer.ColumnAliasMapping);
entityChild = baseEntityChild;
}
if (parentEntity != null)
parentEntity.State = State.UpToDate;
if (reference != null)
reference.State = State.UpToDate;
// mark the reference as loaded for each parentEntity
foreach (Entity e in entities)
if (!e.InferredReferences.Contains(refName))
e.InferredReferences.Add(refName);
}
}
_Transaction.Commit();
}
catch (Exception e)
{
_Transaction.Rollback();
throw e;
}
finally
{
_Connection.Close();
}
}
}
}