A parameter named "p__linq__0" already exists in the parameter collection. Parameter names must be unique in the parameter collection

This is a strange error I get from the Entity Framework: "A parameter named" p_linq_0 "already exists in the parameter collection. The parameter names must be unique in the parameter collection." I am not doing any custom parameters or anything unusual, just direct LINQ queries or executing stored procedures, nothing unusual, nothing unusual, not Entity SQL ... so why does this error happen?

Thank.

+3
source share
2 answers

I had the same problem - I was running multiple requests in parallel in my Task.Runs.

, var ids = _someList.Select(x => x.Thing.Id).Distinct()

, string.Join(",", ids) .

, : .

, string.Join(",", ids), ( ), (p_linq_0).

.ToList() , , .

var ids = _someList.Select(x => x.Thing.Id).Distinct().ToList();

+2

, , . , , . , . , , :

context.Tests.Where(t => t.TypeId == TestTypeId.SingleTimeWholeClass)

, int :

context.Tests.Where(t => (int)t.TypeId == (int)TestTypeId.SingleTimeWholeClass)

. .

0

All Articles