transactionscope

How can I use TransactionScope with SQL Compact 4.0 and NHibernate

血红的双手。 提交于 2019-12-24 00:07:09
问题 I am trying to use NHibernate in combination with .NET's TransactionScope object. So far I have successfully used Oracle 11g and SQL Server 2008R2 with no issues. However, SQL Compact seems to fall on its face. using (var scope = new TransactionScope(TranactionScopeOption.Required)) { using (var session = _sessionFactory.OpenSession()) { // The line below throws. I also tried passing in System.Data.IsolationLevel.ReadCommitted to no avail using (var txn = session.BeginTransaction()) { //

How to perform a transaction with an Entity Framework object context?

你。 提交于 2019-12-23 17:29:04
问题 I created very a simple database using Entity Framework 4. I'd like to be able to use transactions on entities, but I can't seem to keep changes from rolling back. I really just need a way to abandon temporary changes to entities before they are saved to the database. For example, the following code uses an entity framework object context "MusicContainer". Inside a TransactionScope, an Artist entity is created. The transaction then ends without being completed; so I'd expect the transaction

Using TransactionScope with SQLite causes database locked exception

*爱你&永不变心* 提交于 2019-12-23 13:33:27
问题 I am trying to adapt a c# code that uses TransactionScope and works with Oracle to work also with SQLite. My code is structured in a way that every method called within the transaction scope that accesses the SQLite database creates its own SQLiteConnection object. Now I have run into a problem when trying to open a second connection within the TransactionScope block. I am taking care to properly dispose of all the unused SQLiteConnection objects by either wrapping them in a using statement

maxTimeout value from Machine.Config is not picked up by C# winform app

China☆狼群 提交于 2019-12-23 13:11:17
问题 I have been working on a winform app with Oracle 10g database which is using TransactionScope and wanted to modify the maxTimeOut value specified in machine.config file, my machine.config file is in the following location (I am using .net 4 for this app) C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config Originally there was not anything specified for maxTimeOut in it, therefore it defaults to 10 minutes. In order to change it I have added the maxTimeout="00:00:10" value as seen below:

TransactionScope/SqlTransaction timeout extension

做~自己de王妃 提交于 2019-12-23 11:54:40
问题 Is it possible to extend the timeout of a transaction (with SQL Server) once the transaction has started? 回答1: The timeout is "external" to SQL Server, so SQL Server can not affect it. So "no" unfortunately 回答2: I doubt it, but you could rollback and retry. 来源: https://stackoverflow.com/questions/4723944/transactionscope-sqltransaction-timeout-extension

TransactionScope not rolling back transaction

亡梦爱人 提交于 2019-12-23 07:03:11
问题 Here is the current architecture of my transaction scope source code. The third insert throws an .NET exception (Not a SQL Exception) and it is not rolling back the two previous insert statements. What I am doing wrong? EDIT: I removed the try/catch from insert2 and insert3. I also removed the exception handling utility from the insert1 try/catch and put "throw ex". It still does not rollback the transaction. EDIT 2: I added the try/catch back on the Insert3 method and just put a "throw" in

how to implement Unit Of Work just using just TransactionScope and sqlconnections

六月ゝ 毕业季﹏ 提交于 2019-12-23 02:43:15
问题 I am working on a existing system(asp.net 2, ms sql server 2005) where repository pattern is implemented like: IMyRepository { void add(object o); int update(object obj); int delete(object obj); IList<T> getAll(); IList<T> getByDate(DateTime date); .... } The system has 3 different products. So We have different repository for each product. As the requirement changes over time, we need to implement Unit Of Work pattern for business process level transaction. We don't have any ORM.(actually we

Missing support for ambient transactions in nhibernate?

元气小坏坏 提交于 2019-12-23 01:37:21
问题 I know NHibernate supports ambient transactions, because NHibernate sessions enlists in the ambient transactions while inside a transaction scope. However, there are some oddities, consider the following test: [Test] public void Transaction_RollsBackTransactionInsideOfAmbientTransaction_AmbientTransactionAborted() { // arrange ISessionFactory sessionFactory = SessionFactoryOneTimeInitializer.GetTestSessionFactory(); ISession session = sessionFactory.OpenSession();

DTC firewall requirements?

有些话、适合烂在心里 提交于 2019-12-22 08:45:03
问题 I'm attempting to set up an environment in which a TransactionScope originating on a web server (asp.net) will flow a transaction through WCF to an application server and subsequently through to the database. Since I'm forced to use a SQL Server 2005 database, this often causes the transaction to be 'promoted' to a distributed transaction (several service calls could be wrapped in this TransactionScope), which means the Distributed Transaction Coordinator needs to be enabled. I've

How to wrap IDbTransactions in a TransactionScope

佐手、 提交于 2019-12-22 08:21:30
问题 I have several code methods that look like this: using (var connection = this.connectionFactory.GetConnection()) { connection.Open(); using (var transaction = connection.BeginTransaction()) { using (var command = connection.CreateCommand()) { command.Transaction = transaction; command.CommandText = "foo"; command.ExecuteNonQuery(); transaction.Commit(); } } } I now need to call several of these methods together inside an outer transaction, So I did this: using (var transactionScope = new