I have two queries that should do the same job:
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()
However the first works like charm but is slower, the second one returns empty list. this is strange because I have checked the sql code in SSMS and it provided good results. What can be the reason for this behaviour.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.