Skip to content

连表删除很慢 #1513

Answered by 2881099
pengxinglove asked this question in Q&A
May 11, 2023 · 3 comments · 1 reply
Discussion options

You must be logged in to vote

如果实体类多个键无法改变,可以如下解决

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()

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@pengxinglove
Comment options

Answer selected by pengxinglove
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants