我有两个应该做同样工作的查询:
1
var date = DateTime.
var q = _entityManager.Websites.Include("OfflineSites")
.Where(website => (website.LastCheck == null) || SqlFunctions.DateDiff("minute", website.LastCheck.Value, date) >= website.CurrentPingTime);
q.QueryStrategy = QueryStrategy.DataSourceOnly;
var lst = q.Execute().Cast<Website>().ToList();
2
var query = new PassthruEsqlQuery(typeof(Website), @"Select * From Websites Where Id in (Select Id From (Select Id,CurrentPingTime,Abs(DateDiff(minute,CURRENT_TIMESTAMP,LastCheck)) LastCheckDiffNow From Websites )
as ret Where CurrentPingTime <= LastCheckDiffNow)");
query.QueryStrategy = QueryStrategy.DataSourceOnly;
var result = query.With(_entityManager).Execute().Cast<Website>();
var lst = result.ToList()
然而,第一个像魅力一样工作但速度较慢,第二个返回空列表。这很奇怪,因为我检查了SSMS中的sql代码,它提供了很好的结果。这种行为可能是什么原因。