空引用 FreeSql.DbContext.Flush Command()\n at FreeSql.DbSet`1.DbContextFlushCommand
查询:
{"ClassName":"Sys
tem.NullReferenceException","Message":"Object reference not set
to an instance of an object.","Data":null,"InnerException":null,
"HelpURL":null,"StackTraceString":" at FreeSql.DbContext.Flush
Command()\n at FreeSql.DbSet1.DbContextFlushCommand()\n at FreeSql.DbSet1.OrmSelect(Object dywhere)\n at FreeSql.Reposit
oryDbSet1.OrmSelect(Object dywhere)\n at FreeSql.RepositoryDb Set1.OrmSelectInternal(Object dywhere)\n at FreeSql.BaseRepos
itory`1.get_Select()\n at。。。
修改:
{"ClassName":"System.InvalidOperationException"
,"Message":"Queue empty.","Data":null,"InnerException":null,"Hel
pURL":null,"StackTraceString":" at System.Collections.Generic.
Queue1.ThrowForEmptyQueue()\n at System.Collections.Generic.Q ueue1.Dequeue()\n at FreeSql.DbContext.FlushCommand()\n at
FreeSql.RepositoryDbContext.SaveChanges()\n at FreeSql.BaseRep
ository`1.Update(TEntity entity)\n at 。。。。
atsonBuckets":null}
问题描述及重现代码:
并发高的情况下,会发生空引用。 是DbContextFlushCommand 相关的。
c# code
basic repository
数据库版本
mysql 8.0
安装的Nuget包
.net framework/. net core? 及具体版本
.net core 8.0
不用怀疑是并发,是肯定的。
同一个 DbContext 对象被并发使用了。
@24code DbContext 或 UnitOfWork 对象设计时就不支持线程并发。