本文整理汇总了C#中FirebirdSql.Data.FirebirdClient.FbTransaction类的典型用法代码示例。如果您正苦于以下问题:C# FbTransaction类的具体用法?C# FbTransaction怎么用?C# FbTransaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FbTransaction类属于FirebirdSql.Data.FirebirdClient命名空间,在下文中一共展示了FbTransaction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
private void Init(FirebirdProcessor processor, IEnumerable<string> columnDefinitions)
{
Connection = (FbConnection)processor.Connection;
Transaction = (FbTransaction)processor.Transaction;
Create(columnDefinitions);
}
示例2: _executeNonQuery
protected string _executeNonQuery(FbConnection conn, FbTransaction trans, string query, Dictionary<string, object> prms, bool isReturning)
{
string ret = "";
using (FbCommand cmd = new FbCommand(query, conn, trans))
{
foreach (var prm in prms)
cmd.Parameters.AddWithValue(prm.Key, prm.Value);
if (isReturning)
{
FbParameter outparam = new FbParameter("@out", FbDbType.VarChar)
{
Direction = ParameterDirection.Output
};
cmd.Parameters.Add(outparam);
cmd.ExecuteNonQuery();
ret = outparam.Value as string;
}
else
cmd.ExecuteNonQuery();
}
return ret;
}
示例3: _executeReader
protected List<Dictionary<string, string>> _executeReader(FbConnection conn, FbTransaction trans, string query, Dictionary<string, object> prms)
{
List<Dictionary<string, string>> ret = new List<Dictionary<string, string>>();
using (FbCommand cmd = new FbCommand(query, conn, trans))
{
foreach (var prm in prms)
cmd.Parameters.AddWithValue(prm.Key, prm.Value);
using (FbDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
Dictionary<string, string> row = new Dictionary<string, string>();
Object[] values = new Object[reader.FieldCount];
reader.GetValues(values);
for (int jj = 0; jj < reader.FieldCount; jj++)
row.Add(reader.GetName(jj).ToLower(), values[jj].ToString());
ret.Add(row);
}
}
}
return ret;
}
示例4: Get
public int? Get(FbConnection conn, FbTransaction trans, int objectId, string code, bool createIfNotExist)
{
string query = "SELECT * FROM sp_get_collection(@objectid, @collectioncode, @createifnotexist)";
int? ret = null;
try
{
using (FbCommand cmd = new FbCommand(query, conn, trans))
{
cmd.Parameters.AddWithValue("@objectid", objectId);
cmd.Parameters.AddWithValue("@collectioncode", code);
cmd.Parameters.AddWithValue("@createifnotexist", createIfNotExist);
using (FbDataReader reader = cmd.ExecuteReader())
{
if (reader.Read())
{
ret = !reader.IsDBNull(0) ? reader.GetInt32(0) as int? : null;
}
}
}
}
catch (Exception ex)
{
throw new Exception(String.Format("Ошибка SQL запроса. {0}", ex.Message));
}
return ret;
}
示例5: Find
public List<int> Find(FbConnection conn, FbTransaction trans, int ownerObjectId, string collectionName, string attrName, string attrValue)
{
string query = "SELECT objectid FROM sp_find_objects(@ownerObjectId, @collectionName, @attrName, '=', @attrValue)";
List<int> ret = new List<int>();
try
{
using (FbCommand cmd = new FbCommand(query, conn, trans))
{
cmd.Parameters.AddWithValue("ownerObjectId", ownerObjectId);
cmd.Parameters.AddWithValue("collectionName", collectionName);
cmd.Parameters.AddWithValue("attrName", attrName);
cmd.Parameters.AddWithValue("attrValue", attrValue);
using (FbDataReader reader = cmd.ExecuteReader())
{
if (reader.Read())
{
ret.Add(reader.GetInt32(0));
}
}
}
}
catch (Exception ex)
{
throw new Exception(String.Format("Ошибка SQL запроса. {0}", ex.Message));
}
return ret;
}
示例6: Select
public IModel Select(FbConnection conn, FbTransaction trans, string code)
{
string query = "SELECT * FROM models WHERE modelcode = UPPER(@modelcode)";
IModel ret = null;
try
{
using (FbCommand cmd = new FbCommand(query, conn, trans))
{
cmd.Parameters.AddWithValue("modelcode", code.ToUpper());
using (FbDataReader reader = cmd.ExecuteReader())
{
if (reader.Read())
{
ret = new Model
{
Id = reader.GetInt32(0),
Code = reader.GetString(1),
ObjectIdRoot = reader.GetInt32(2)
};
}
}
}
}
catch (Exception ex)
{
throw new Exception(String.Format("Ошибка SQL запроса. {0}", ex.Message));
}
return ret;
}
示例7: Add
public int? Add(FbConnection conn, FbTransaction trans, int collectionId)
{
string query = "SELECT * FROM sp_add_object(@collectionId)";
int? ret = null;
try
{
using (FbCommand cmd = new FbCommand(query, conn, trans))
{
cmd.Parameters.AddWithValue("collectionId", collectionId);
using (FbDataReader reader = cmd.ExecuteReader())
{
if (reader.Read())
{
ret = !reader.IsDBNull(0) ? reader.GetInt32(0) as int? : null;
}
}
}
}
catch (Exception ex)
{
throw new Exception(String.Format("Ошибка SQL запроса. {0}", ex.Message));
}
return ret;
}
示例8: TransactionSubstance
/// <summary>
/// 指定されたパラメタでインスタンスを生成します。
/// </summary>
/// <param name="connectionSubstance">接続実体オブジェクト</param>
internal TransactionSubstance(ConnectionSubstance connectionSubstance)
{
this.count = 0;
this.isRollback = false;
this.connectionSubstance = connectionSubstance;
this.transaction = this.connectionSubstance.FbConnection.BeginTransaction(Transaction.FbTransactionOption);
this.commandList = new List<Command>();
this.disposed = false;
}
示例9: Delete
/// <summary>
/// Удаление пользователя
/// </summary>
/// <param name="user">Пользователь</param>
/// <param name="connection">Соединение</param>
/// <param name="transaction">Транзакция</param>
public static void Delete(UserData user, FbConnection connection,
FbTransaction transaction)
{
// создаем команду
using (FbCommand command = new FbCommand("delete from users where id = @id",
connection, transaction))
{
// параметры команды
command.Parameters.Add("@id", user.Id);
// выполняем команду
command.ExecuteNonQuery();
}
}
示例10: Exists
/// <summary>
/// Проверка существования записи в базе
/// </summary>
/// <param name="user">Пользователь</param>
/// <param name="connection">Соединение</param>
/// <param name="transaction">Транзакция</param>
public static Boolean Exists(UserData user, FbConnection connection,
FbTransaction transaction)
{
// создаем команду
using (FbCommand command = new FbCommand("select id from users where id = @id",
connection, transaction))
{
// параметры команды
command.Parameters.Add("@id", user.Id);
// выполняем команду
using (FbDataReader reader = command.ExecuteReader())
{
// возвращаем результат поиска
return reader.Read();
}
}
}
示例11: Delete
public void Delete(FbConnection conn, FbTransaction trans, int ownerObjectId, string code)
{
string query = "DELETE FROM collections WHERE owner_objectid = @owner_objectid AND collectioncode = UPPER(@collectioncode)";
try
{
using (FbCommand cmd = new FbCommand(query, conn, trans))
{
cmd.Parameters.AddWithValue("@owner_objectid", ownerObjectId);
cmd.Parameters.AddWithValue("@collectioncode", code);
cmd.ExecuteNonQuery();
}
}
catch (Exception ex)
{
throw new Exception(String.Format("Ошибка SQL запроса. {0}", ex.Message));
}
}
示例12: Set
public void Set(FbConnection conn, FbTransaction trans, int objectId, string code, string val)
{
string query = "EXECUTE PROCEDURE sp_set_attribute(@objectId, @attributeCode, @val)";
try
{
using (FbCommand cmd = new FbCommand(query, conn, trans))
{
cmd.Parameters.AddWithValue("objectId", objectId);
cmd.Parameters.AddWithValue("attributeCode", code);
cmd.Parameters.AddWithValue("val", val);
cmd.ExecuteNonQuery();
}
}
catch (Exception ex)
{
throw new Exception(String.Format("Ошибка SQL запроса. {0}", ex.Message));
}
}
示例13: Delete
public int Delete(FbConnection conn, FbTransaction trans, int id)
{
string query = "EXECUTE PROCEDURE sp_delete_object(@id)";
int ret = -1;
try
{
using (FbCommand cmd = new FbCommand(query, conn, trans))
{
cmd.Parameters.AddWithValue("id", id);
ret = cmd.ExecuteNonQuery();
}
}
catch (Exception ex)
{
throw new Exception(String.Format("Ошибка SQL запроса. {0}", ex.Message));
}
return ret;
}
示例14: Insert
/// <summary>
/// Добавление пользователя
/// </summary>
/// <param name="user">Пользователь</param>
/// <param name="connection">Соединение</param>
/// <param name="transaction">Транзакция</param>
public static void Insert(UserData user, FbConnection connection,
FbTransaction transaction)
{
// текст команды
StringBuilder commandText = new StringBuilder();
commandText.Append("insert into users values ");
commandText.Append("(@id, @name, @password, @group, @can_close, @cashier_mode_only)");
// создаем команду
using (FbCommand command = new FbCommand(commandText.ToString(), connection, transaction))
{
// параметры
command.Parameters.Add("@id", user.Id);
command.Parameters.Add("@name", user.Name);
command.Parameters.Add("@password", user.Password);
command.Parameters.Add("@group", (Int32)user.SecurityGroup);
command.Parameters.Add("@can_close", user.CanClose ? 1 : 0);
command.Parameters.Add("@cashier_mode_only", user.CashierModeOnly ? 1 : 0);
// выполняем команду
command.ExecuteNonQuery();
}
}
示例15: FbCommand
public FbCommand(string cmdText, FbConnection connection, FbTransaction transaction)
: base()
{
this.namedParameters = new List<string>();
this.updatedRowSource = UpdateRowSource.Both;
this.commandType = CommandType.Text;
this.designTimeVisible = true;
this.commandTimeout = 30;
this.fetchSize = 200;
this.commandText = string.Empty;
if (connection != null)
{
this.fetchSize = connection.ConnectionOptions.FetchSize;
}
if (cmdText != null)
{
this.CommandText = cmdText;
}
this.Connection = connection;
this.transaction = transaction;
}