OrderBy and Distinct using LINQ-to-Entities

Posted by BlueRaja on Stack Overflow See other posts from Stack Overflow or by BlueRaja
Published on 2010-03-12T20:07:32Z Indexed on 2010/03/12 20:27 UTC
Read the original article Hit count: 993

Here is my LINQ query:

(from o in entities.MyTable
orderby o.MyColumn
select o.MyColumn).Distinct();

Here is the result:

{"a", "c", "b", "d"}

Here is the generated SQL:

SELECT 
[Distinct1].[MyColumn] AS [MyColumn]
FROM ( SELECT DISTINCT 
    [Extent1].[MyColumn] AS [MyColumn]
    FROM [dbo].[MyTable] AS [Extent1]
)  AS [Distinct1]

Is this a bug? Where's my ordering, damnit?

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about linq-to-entities