一、如下图所示,当我用 .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语句是可以查出来结果的。