Alex Kibler
Alex Kibler

Reputation: 4954

EntitySpaces query returns no results, but if I run the same query, I get 1 record

I'm working on adding a new feature to a legacy ServiceStack application that uses EntitySpaces. I am building out a very simple SQL query, and when I execute it, it returns no records at all. If I set a breakpoint right where it attempts to load the collection, copy the query, and execute it in SSMS, I get the record I'm looking for. But when I let ES execute it, it gets 0 results.

Here is the query.

SELECT pchtq.[status], 
       pchtq.[amount], 
       pchtq.[recordcreatedatetime], 
       utaq.[username], 
       utaq.[fullname] 
FROM   [DATABASE].[dbo].[transactions] pchtq 
       INNER JOIN [DATABASE].[dbo].[userinfo] utaq 
               ON pchtq.[id] = utaq.[id] 
WHERE  ( ( ( pchtq.[recordcreatedatetime] >= '01/01/2009' 
             AND pchtq.[recordcreatedatetime] <= '05/10/2016' ) 
           AND Upper(pchtq.[status]) = 'PAID' ) 
          OR Upper(pchtq.[status]) = 'AUDIT' )   

and here's the C#

pchtq
.Select(
    pchtq.Status,
    pchtq.Amount,
    pchtq.RecordCreateDateTime,                    
    utaq.UserName,
    utaq.FullName)
.InnerJoin(utaq).On(pchtq.id== utaq.id)
.Where(pchtq.RecordCreateDateTime >= request.StartDate 
    && pchtq.RecordCreateDateTime <= request.EndDate 
    && pchtq.Status.ToUpper() == "PAID" || pchtq.Status.ToUpper() == "AUDIT");


if (pchtc.Load(pchtq))
{
     //stuff
}

Like I said, the actual SQL query, when executed, returns 1 row (which is what I expect). The C# returns nothing. Also, the parameters in the query are the same between the SQL and the C#

Upvotes: 0

Views: 193

Answers (0)

Related Questions