以下基本的LINQ to SQL语句无法按照orderby排序。从T-SQL中可以看出,没有进行排序。你知道为什么吗?
LINQ to SQL:
var results = (from stats in db.t_harvest_statistics
orderby stats.unit_number
select stats.unit_number).Distinct().ToList();
以上结果对应以下 TSQL
SELECT
[Distinct1].[unit_number] AS [unit_number]
FROM ( SELECT DISTINCT
[Extent1].[unit_number] AS [unit_number]
FROM [dbo].[t_harvest_statistics] AS [Extent1]
) AS [Distinct1]