0

我正在使用 BLToolkit 并发现了一个有趣的行为。我不明白为什么在链接中使用相同的请求会给我不同的结果: SQL 请求:


select TOP 1 * from table where  coverCode='1+4' 
                                             and effectiveDate <='20130103' 
                                              and  maxValue >= '1000'  
                                             order by maxValue asc, effectivedate desc

该表实际上有两个结果:

  • A) (id): 1ffbe215-ff0e-47dd-9718-4130ffb62539 (maxValue): 1000 (effDate):2011-01-01 (price):40

  • B) (id): b787a74e-696b-493d-a4bc-5bb407e231b3 (maxValue):1000 (effDate):2011-01-01 (price):80

SQL 请求给了我 A 结果。同时使用Linq的请求:

db.Rate
   .Where(x=>x.coverCode == "1+4"
           && x.effectiveDate <= '20130103'
            && x.MaxValue >= '1000')
            .OrderBy(x => x.MaxValue)
            .ThenByDescending(x => x.effectiveDate)

这个请求给了我 B 结果。谁能解释 linq 请求中的原因或问题?

4

1 回答 1

1

您可能想db.LastQuery在执行 LINQ 代码后检查您的权限。您将看到生成的 SQL,并且可以将其与您真正想要的 SQL 进行比较。

于 2013-02-18T06:28:46.657 回答