使用Linq,怎样实现可变条件的查询

2025-04-24 21:26:25
推荐回答(1个)
回答1:

#Default.aspx.cs方法: ClassLibrary1.Help h = new ClassLibrary1.Help(); string sqlWhere = "1=1"; if (txttitle.Text != "") { sqlWhere += " and title like '%" + txttitle.Text + "%'"; } if (txtlmmc.Text != "") { sqlWhere += " and .