C# 向DateTime添加秒数的NHibernate.Linq查询问题
在使用NHibernate.Linq和Entity Framework 6.0时,我收到以下异常 NHibernate.QueryException:无法在没有投影的条件上使用子查询。 问题具体来自:C# 向DateTime添加秒数的NHibernate.Linq查询问题,c#,linq,entity-framework,nhibernate,fluent-nhibernate,C#,Linq,Entity Framework,Nhibernate,Fluent Nhibernate,在使用NHibernate.Linq和Entity Framework 6.0时,我收到以下异常 NHibernate.QueryException:无法在没有投影的条件上使用子查询。 问题具体来自: taco.LastRun <= DbFunctions.AddSeconds(taco.LastRun, taco.PeriodSeconds) taco.LastRun我认为这是因为您正在更新select查询中的信息。 此更新本身将是某种查询(可能是update SQL语句) 尝试先更新
taco.LastRun <= DbFunctions.AddSeconds(taco.LastRun, taco.PeriodSeconds)
taco.LastRun我认为这是因为您正在更新select查询中的信息。
此更新本身将是某种查询(可能是update SQL语句)
尝试先更新信息,然后执行select查询
但是看看你想做什么并没有多大意义,就像
taco.lastrun0)。
但我想我知道你想做什么:
var results = (
from taco in Session.Linq<Taco>()
where
taco.IsActive && !taco.IsProcessing &&
((taco.StartCrunching == null) || (taco.StartCrunching <= currentDateTime)) &&
((taco.Cycles == null) || (taco.CycleCount < taco.Cycles)) &&
(taco.LastRun == null || (taco.LastRun <= currentDateTime.AddSeconds(taco.PeriodSeconds)))
&& ((taco.EndCrunching == null))
select taco).ToList();
var结果=(
来自会话中的taco.Linq()
哪里
taco.IsActive&!taco.IsProcessing&&
((Too.StcRunung==NULL)”(Too.StcRununGHD NHiBiNATE。Linq是非常非常老的。如果您还没有这样做,考虑升级到NHiBiNess 3.4或4,它是对LINQ的内置支持,这大大改进了。
var results = (
from taco in Session.Linq<Taco>()
where
taco.IsActive && !taco.IsProcessing &&
((taco.StartCrunching == null) || (taco.StartCrunching <= currentDateTime)) &&
((taco.Cycles == null) || (taco.CycleCount < taco.Cycles)) &&
(taco.LastRun == null || (taco.LastRun <= currentDateTime.AddSeconds(taco.PeriodSeconds)))
&& ((taco.EndCrunching == null))
select taco).ToList();