orderby entity.Count => "ORDER BY SELECT COUNT(*)"

16 views
Skip to first unread message

VD

unread,
Oct 22, 2010, 6:00:06 AM10/22/10
to DbLinq
Hi,

I have faced with a problem when I used class with property "Count".
When I use this property in orderby clause, it generates to wrong
query: SELECT ... FROM ... ORDER BY SELECT COUNT(*). I discovered, why
it happend. There is some strange code: the class ExpressionDispatcher
(DbLinq.Data.Linq.Sugar.Implementation namespace), method
AnalyzeMember(Expression expression, BuilderContext builderContext)
contains chek:

if (!isStaticMemberAccess && memberInfo.Name == "Count")
return
AnalyzeProjectionQuery(SpecialExpressionType.Count, new[]
{ memberExpression.Expression }, builderContext);

This code leads to the described above problem. Can somebody describe
to me what this code means, and for what reasons it was written? If I
understood the logic, Count expression never can be a
MemberExpression, it is a CallExpression. As I know linq it doesn't
contain expression like "select someTable.count()".. Mey be it is bug?

Thanks.
Reply all
Reply to author
Forward
0 new messages