一、如下圖所示,當我用?.WhereIF(input.Plancontroltype > 0, u => u.Plancontroltype== (DnjqPlancontroltype)input.Plancontroltype)? ? 這里面用等于的時候,返回結果一條數據都沒有。
上圖中生成的SQL如下:
?SELECT `id` AS `Id` ,`code` AS `Code` ,`name` AS `Name` ,`namenum` AS `Namenum` ,`realnamenum` AS `Realnamenum` ,`batchsn` AS `Batchsn` ,`plateweight` AS `Plateweight` ,`totalweight` AS `Totalweight` ,`plancontroltype` AS `Plancontroltype` ,`outside` AS `Outside` ,`productbz` AS `Productbz` ,`userdef1` AS `Userdef1` ,`userdef2` AS `Userdef2` ,`create_user_id` AS `CreateUserId` ,`create_user` AS `CreateUser` ,`update_user_id` AS `UpdateUserId` ,`update_user` AS `UpdateUser` ,`create_time` AS `CreateTime` ,`update_time` AS `UpdateTime` ,`is_delete` AS `IsDelete` FROM `hk_dnjq_productplan` ? WHERE ( `plancontroltype` = 2 ) ?AND ( `is_delete` = 0 ) ?ORDER BY `create_time` DESC LIMIT 0,100
二、然后我把??.WhereIF(input.Plancontroltype > 0, u => u.Plancontroltype>= (DnjqPlancontroltype)input.Plancontroltype) 改成 >=? ?。? 他就能查出來3條數據了。
如下圖所示:
上圖產生的sql如下:
?SELECT `id` AS `Id` ,`code` AS `Code` ,`name` AS `Name` ,`namenum` AS `Namenum` ,`realnamenum` AS `Realnamenum` ,`batchsn` AS `Batchsn` ,`plateweight` AS `Plateweight` ,`totalweight` AS `Totalweight` ,`plancontroltype` AS `Plancontroltype` ,`outside` AS `Outside` ,`productbz` AS `Productbz` ,`userdef1` AS `Userdef1` ,`userdef2` AS `Userdef2` ,`create_user_id` AS `CreateUserId` ,`create_user` AS `CreateUser` ,`update_user_id` AS `UpdateUserId` ,`update_user` AS `UpdateUser` ,`create_time` AS `CreateTime` ,`update_time` AS `UpdateTime` ,`is_delete` AS `IsDelete` FROM `hk_dnjq_productplan` ? WHERE ( `plancontroltype` >= 2 ) ?AND ( `is_delete` = 0 ) ?ORDER BY `create_time` DESC LIMIT 0,100
三、而實際上我的數據表中plancontroltype字段是有2行等于2 的數據的, 按理說用==條件應該是可以查出來數據的。 如下圖分別展示了 sql語句的>= 和=條件查出來的結果。
我還試過?代碼里用<= 的判斷,也查不出來結果,但是用sql語句是可以查出來結果的。