我的问题很简单,但我仍然搜索了 2 多个小时才能找到解决方案。在 C# 中,我有一个 where 子句:where ?hospitalID然后我将这个值(hospitalID)与我的条件绑定:
cmd.Parameters.AddWithValue("?hospitalID", (filters.hospitalID != 0) ? "operation.hospitalID=" + filters.hospitalID : "true");所以我在这里要说的是:如果变量 filters.hospitalID 不为零,则继续创建条件 ( where operation.hospitalID=filters.hospitalID)。否则“无效”条件 ( where true)。
如果我手动更改字符串,where operation.hospitalID=2它会起作用。但是使用 AddWithValue 方法,它根本不起作用。
慕的地6264312
慕森卡
www说
随时随地看视频慕课网APP
相关分类