Entity framework 4 Linq到实体比较子查询中的日期时间
我正在尝试执行以下子查询:Entity framework 4 Linq到实体比较子查询中的日期时间,entity-framework-4,linq-to-entities,Entity Framework 4,Linq To Entities,我正在尝试执行以下子查询: var query = from cjto in oContext.t_table_1 join cav in oContext.t_table_2 on cjto.cd_code equals cav.cd_code where cav.dt_time >= (from tu in oContext.t_table3 where tu.vl_code == "ABCD" select
var query =
from cjto in oContext.t_table_1
join cav in oContext.t_table_2 on cjto.cd_code equals cav.cd_code
where cav.dt_time >=
(from tu in oContext.t_table3
where tu.vl_code == "ABCD"
select tu.dt_check_time)
select cav;
但是,我得到了一个错误:
Operator '>=' cannot be applied to operands of type 'System.DateTime' and 'System.Linq.IQueryable<System.DateTime?>'
运算符'>='不能应用于'System.DateTime'和'System.Linq.IQueryable'类型的操作数
如何实现这样的查询?好的,我知道了。。。我需要添加
FirstOrDefault()
,以便获得第一个元素
var query =
from cjto in oContext.t_table_1
join cav in oContext.t_table_2 on cjto.cd_code equals cav.cd_code
where cav.dt_time >=
(from tu in oContext.t_table3
where tu.vl_code == "ABCD"
select tu.dt_check_time).FirstOrDefault()
select cav;
好的,我知道了。。。我需要添加
FirstOrDefault()
,以便获得第一个元素
var query =
from cjto in oContext.t_table_1
join cav in oContext.t_table_2 on cjto.cd_code equals cav.cd_code
where cav.dt_time >=
(from tu in oContext.t_table3
where tu.vl_code == "ABCD"
select tu.dt_check_time).FirstOrDefault()
select cav;
Tks