How is the SQL generated for the .Count() extension method?

The current bug I'm seeing is that for the C# code:

        int count =
            (from p in Context.GetTable<Person>()
             orderby p.LastName
             select p)
            .Count();

the following SQL is generated for Microsoft SQL Server:

        SELECT COUNT(*)
        FROM [people]
        ORDER BY [last_name]

SQL Server doesn't like this SQL because of the 'ORDER BY' clause.
After a slightly more than cursory perusal, I'm not sure why the 'ORDER
BY' is being generated here, nor am I sure how to fix this.

Thoughts?
 - Jon



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DbLinq" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/dblinq?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to