高频查询PostgreSQL数据会发生表名解析错误或空引用 返回
高频掉用以下代码,数据库表名解析发生错误:
var components = await _db.APS.Queryable<SimulateBOMComponent>()
.Where(x => x.plant_code == plantCode && x.parent_material_no == parentMaterialNo)
.ToListAsync();
正常AOP解析为:
[Sql]:SELECT "id","simulateno","plant_code","parent_material_no","child_material_no","usage_qty","baseqty","loss_rate","issue_unit","issue_unit_fac","source_code","createdtime" FROM "sys_sim_bomcomponent" WHERE (( "plant_code" = @plant_code0 ) AND ( "parent_material_no" = @parent_material_no1 ))
[Pars]:
[Name]:@plant_code0 [Value]:YLD001 [Type]:String
[Name]:@parent_material_no1 [Value]:33018020037 [Type]:String
偶尔发送错误解析:
[Sql]:SELECT "id","simulateno","plant_code","parent_material_no","child_material_no","usage_qty","baseqty","loss_rate","issue_unit","issue_unit_fac","source_code","createdtime" FROM "simulatebomcomponent" WHERE (( "plant_code" = @plant_code0 ) AND ( "parent_material_no" = @parent_material_no1 ))
[Pars]:
[Name]:@plant_code0 [Value]:YLD001 [Type]:String
[Name]:@parent_material_no1 [Value]:120836403009 [Type]:String
也会发送以下空异常:
System.NullReferenceException:“Object reference not set to an instance of an object.”
at SqlSugar.ContextMethods.GetReflectionInoCacheInstance()
麻烦看看是否有遇到此同类问题及处理对策,谢谢!
SqlSugarCore版本:V5.1.4.214
热忱回答(4)
-
fate sta VIP0
2026/3/17目前正常情况不会出现这种情况,除非你改了entityInfo里面的东西。
0 回复 -
fate sta VIP0
2026/3/17写可以写DEMO进行测试。
0 回复 -
fate sta VIP0
2026/3/17entityInfo 只能在entityService 和 entityServiceName修改,其他地方不能修改 entityInfo
0 回复 -
fate sta VIP0
2026/3/17如果是线程安全问题
_db.APS.改成_db.APS.CopyNew()
0 回复