当我尝试在 Linq Pad 中运行查询时出现上述错误,如下所示,
var qry = (from i in INTERNETDATAs
join c in COVERS on Convert.ToInt32(i.COVERTYPE) equals c.COV_TYPE
where i.DATELOADED >= new DateTime(2013,7,1)
&& i.DATELOADED < new DateTime(2013,8,1)
&& i.CAMPAIGNTYPE == "4"
&& c.COVERTYPEID == 17063789
&& c.CHILDAPPLIES != 1
&& c.SPOUSEAPPLIES != 1
select i
);
qry.Dump();
我的 COVERS 表中的 c.CHILDAPPLIES 和 c.SPOUSEAPPLIES 列属于 (bit, null) 类型。
我的 Sql 查询工作正常,如下所示,但我的 LINQ 查询给出错误运算符“!=”不能应用于“布尔”类型的操作数?和'int'
SELECT Count(*)
FROM INTERNETDATA I Join COVERS C ON C.COV_TYPE = CONVERT(int, I.COVERTYPE)
WHERE ((I.DATELOADED >= CONVERT(DATETIME, '1 Jul 2013 00:00:00'))
AND (I.DATELOADED < CONVERT(DATETIME, '1 Aug 2013 00:00:00')))
AND (CONVERT(int, I.COVERTYPE) = C.COV_TYPE)
AND (C.COVERTYPEID = 17063789)
AND (I.CAMPAIGNTYPE = 4)
AND C.CHILDAPPLIES != 1
AND C.SPOUSEAPPLIES !=1
提前致谢。