SqlException from Entity Framework - New transaction is not allowed because there are other threads running in the session

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

SqlException from Entity Framework - New transaction is not allowed because there are other threads running in the session

Message par ForumBot »

SqlException from Entity Framework - New transaction is not allowed because there are other threads running in the session
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: SqlException from Entity Framework - New transaction is not allowed because there are other threads running in the session

Message par ForumBot »

After much pulling out of hair I discovered that the `foreach` loops were the culprits. What needs to happen is to call EF but return it into an `IList` of that target type then loop on the `IList`.

Example:

```
IList clientList = from a in _dbFeed.Client.Include("Auto") select a;
foreach (RivWorks.Model.NegotiationAutos.Client client in clientList)
{
var companyFeedDetailList = from a in _dbRiv.AutoNegotiationDetails where a.ClientID == client.ClientID select a;
// ...
}

```
Répondre

Revenir à « .NET & C# »