gpt4 book ai didi

linq-to-sql - 获取 "The operation is not valid for the state of the transaction.",但我没有使用事务

转载 作者:行者123 更新时间:2023-12-04 02:39:16 25 4
gpt4 key购买 nike

Stack Trace:    at System.Transactions.TransactionState.EnlistPromotableSinglePhase(InternalTransaction tx, IPromotableSinglePhaseNotification promotableSinglePhaseNotification, Transaction atomicTransaction)
at System.Transactions.Transaction.EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification promotableSinglePhaseNotification)
at System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transaction tx)
at System.Data.SqlClient.SqlInternalConnection.Enlist(Transaction tx)
at System.Data.SqlClient.SqlInternalConnectionTds.Activate(Transaction transaction)
at System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser user)
at System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe()
at System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode()
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.All[TSource](IQueryable`1 source, Expression`1 predicate)

此时我没有使用事务或 TransactionScope。如果交易不存在,框架是否会自动创建交易,或者交易是否从某处偷偷进入?

这是 C# .NET 4,使用 LINQ-to-SQL 查询 MS SQL 2008。

最佳答案

当您执行 SaveChanges 时,LINQ to SQL 会创建一个事务,以便提交是原子的 - 即要么保存所有更改,要么不保存。

关于linq-to-sql - 获取 "The operation is not valid for the state of the transaction.",但我没有使用事务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6269104/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com