连表删除很慢 #1513
-
作者好: DELETE 但如果采用 以下这种就很快 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
你的实体类定义的是两个联合主键吧,[FINSIDELOTNO], [FSN] |
Beta Was this translation helpful? Give feedback.
-
如果实体类多个键无法改变,可以如下解决 var sql = db.Select<tb_PP_Lotdetial, Tb_LD_paint_sn>()
.InnerJoin((a, b) => a.FSN == b.sn && a.FINSIDELOTNO == b.lotno)
.Where((a, b) => a.FINSIDELOTNO == dto.LotNo && b.printflag == false)
.ToSql(a=> a.FSN);
fsql.Delete<tb_PP_Lotdetial>()
.Where($"FSN in ({sql})")
.ExexuteAffrows() |
Beta Was this translation helpful? Give feedback.
-
感谢作者的技术支持,让我们能够放心大胆地使用Freesql |
Beta Was this translation helpful? Give feedback.
如果实体类多个键无法改变,可以如下解决