I expect no 'ORDER BY' in that case, i.e. 'SELECT COUNT(*) FROM [people]' (as that doesn't generate an error). (Alternatively, find some other formulation so that SQL Server doesn't reject the 'ORDER BY', but I haven't been able to find such a formulation.)
- Jon On Wed, 2009-05-06 at 09:43 +0200, Pascal Craponne wrote: > What SQL statement do you expect in such a case? > > > On Wed, May 6, 2009 at 06:25, Jonathan Pryor <[email protected]> wrote: > > 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 -~----------~----~----~----~------~----~------~--~---
