I am using your software for a while now and I am bumping into a problem. I want to select the top 5 of a selection and fetch the entities by a getMulti.
The SQL code looks like:
SELECT * FROM Tags WHERE TagID IN
(
SELECT TOP 5 ProductsTags.TagID
FROM ProductsTags
GROUP BY ProductsTags.TagID
ORDER BY COUNT(ProductsTags.TagID) DESC
)
This is the llblgen code I do have so far:
TagsCollection tc = new TagsCollection();
GroupByCollection groupBy = new GroupByCollection();
groupBy.Add(ProductsTagsFields.TagId);
SortExpression sorter = new SortExpression();
sorter.Add(new SortClause(ProductsTagsFields.TagId.SetAggregateFunction(AggregateFunction.Count), SortOperator.Descending));
IPredicateExpression filter = new PredicateExpression();
filter.Add(new FieldCompareSetPredicate(TagsFields.TagId, ProductsTagsFields.TagId, SetOperator.In, null, null, "", 5, sorter, false, groupBy));
tc.GetMulti(filter);
The problem is that the generated llblgen SQL code doesn't contain the count(ProductsTags.TagID) in the Sort By. In other threads I was reading this is possible since version 2. However with my current version 2.5 it doesn't work. Hope you can help me out.
Generated:
"( [Development].[dbo].[Tags].[TagID] IN (SELECT TOP 5 [Development].[dbo].[ProductsTags].[TagID] AS [TagId] FROM [Development].[dbo].[ProductsTags] GROUP BY [Development].[dbo].[ProductsTags].[TagID] ORDER BY TagId DESC))"