简体   繁体   中英

Idaeablade PassthruEsqlQuery returns empty list

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.

Are you sure that this PassthruEsqlQuery isn't actually throwing an error? The PassthruEsqlQuery requires ESQL, not SQL, and what you're showing doesn't look correct. There's some more information on the DevForce query here , and ESQL here .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM